Can't read a peripheral register.

Technical questions regarding the XTC tools and programming with XMOS.
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Can't read a peripheral register.

Post by babazaroni »

First time trying to read a peripheral register, so I'm not confident I'm doing it right.

I'm trying to read the general oscillator control register.

The oscillator is peripheral 4, and the general oscillator control register is at base address 0.

The problem is the following code hangs when it enters read_periph_8.

unsigned char read_vals[1];
read_periph_8(tile[0],4,0,1,read_vals);

Any idea why it hangs?


babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Post by babazaroni »

Found the problem.

I needed to use the usb_tile, not tile[0].

read_periph_8(usb_tile,4,0,1,read_vals);
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Post by babazaroni »

Actually, using usb_tile just stopped the hanging. It appears that usb_tile is not the correct tile to look for the oscillator control register.
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Post by babazaroni »

After studying app_adc_demo_u in sc_u_series_support-master, the solution was to set the target in the makefile as follows:

TARGET = XP-SKC-SU1.xn

This somehow creates a global xs1_su that represents the peripheral tile and can be used as follows:

read_periph_8(xs1_su,XS1_SU_PER_OSC_CHANEND_NUM,XS1_SU_PER_OSC_ON_SI_CTRL_NUM,1,reg_val);
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

TARGET = XP-SKC-SU1.xn

This somehow creates a global xs1_su that represents the peripheral tile and can be used as follows
Yes - the xn file gets compiled into a .h file called platform.h which makes the node identifiers available in your source code.

However, I would have expected

Code: Select all

usb_tile
to have done the trick as your node identifier, from checking the xn file..

Code: Select all

<Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
            <Service Proto="xs1_su_adc_service(chanend c_adc)">
krishnabalan
Member++
Posts: 24
Joined: Thu Aug 14, 2014 10:55 am

Post by krishnabalan »

I am just curious to know whether it is possible to see the "platform.h" file auto-generated from .xn file? (Forgive me as this question is off from the thread topic)
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

krishnabalan wrote:I am just curious to know whether it is possible to see the "platform.h" file auto-generated from .xn file? (Forgive me as this question is off from the thread topic)
You can use the -save-temps compiler option to save all intermediate files, including the platform.h