xcore-200 mc as i2c slave

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
Post Reply
alexjaw
Active Member
Posts: 35
Joined: Wed Jan 24, 2018 9:13 am

xcore-200 mc as i2c slave

Post by alexjaw »

I need to configure app_usb_audio as i2c slave and hope to get some suggestions for how this might be implemented in the software since the default app is configured as i2c master for ADC and DAC control. Have Raspberry pi as i2c master.

Have successfully tested the i2c slave app in AN00157 and imagine that it should be possible to extend app_usb_audio with corresponding i2c slave functionality. Possible sequence for sample change on usb:
0. app_usb_aud detects sample rate change on usb audio
1. app_usb_aud interrupts the pi through a gpio pin.
2. pi as i2c master asks xmos i2c_slave for the required sample rate, provided through the i2c_slave_register_file
3. pi configures the pll for the requested sample rate

I believe that, in principle…, this must be done in app_usb_audio:
* src/extensions/audiohw.xc: remove i2c related ADC/DAC-code, replace init of i2c master to i2c_slave
* module_usb_audio/main.xc: add components such as i2c_slave_register_file() and slave_application() from AN00157 in order to exchange data between raspberry and xmos. Should I also assume that I should put i2c_slave_callback_if i_i2c, and i2c_slave(i_i2c, p_slave_scl, p_slave_sda, device_addr) in main.xc?

All comments appreciated.


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Please review some of the comments here:

http://www.xcore.com/viewtopic.php?f=3& ... =I2c+slave
alexjaw
Active Member
Posts: 35
Joined: Wed Jan 24, 2018 9:13 am

Post by alexjaw »

mon2 wrote:Please review some of the comments here:

http://www.xcore.com/viewtopic.php?f=3& ... =I2c+slave
Have checked that before and it's about i2c communication lines on the board. My main problem is how to add i2c "slavery" application code (similar to AN00157 to app_usb_aud.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Start with AN10126 and post your resource usage for your ip. Need to know if you have the available bandwidth.

Can also use the -report flag in your makefile:

https://www.xmos.com/published/xmos-pro ... =B&page=22
alexjaw
Active Member
Posts: 35
Joined: Wed Jan 24, 2018 9:13 am

Post by alexjaw »

mon2 wrote:Start with AN10126 and post your resource usage for your ip. Need to know if you have the available bandwidth.

Can also use the -report flag in your makefile:

https://www.xmos.com/published/xmos-pro ... =B&page=22
OK, have assumed that there is plenty bandwidth since I will use the same chip as on the xcore200-mca board, i.e. XE216-512-TQ128.
Plan is to use one of the default configurations as starting point,

Creating app_usb_aud_xk_216_mc_2i10o10xxxxxx_slave.xe
Constraint check for tile[0]:
Cores available: 8, used: 2 . OKAY
Timers available: 10, used: 2 . OKAY
Chanends available: 32, used: 5 . OKAY
Memory available: 262144, used: 20512 . OKAY
(Stack: 1444, Code: 15520, Data: 3548)
Constraints checks PASSED.
Constraint check for tile[1]:
Cores available: 8, used: 4 . OKAY
Timers available: 10, used: 6 . OKAY
Chanends available: 32, used: 19 . OKAY
Memory available: 262144, used: 71712 . OKAY
(Stack: 2820, Code: 22572, Data: 46320)
Constraints checks PASSED.
Build Complete
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Now use the AN00157 appnote to insert the i2c master and i2c slave code into this audio project. It should be possible to take the known working code and apply into any project. Test the new code using the same defined test methods from an00157. Afterwards, you can remove any dead code to reduce code size.
alexjaw
Active Member
Posts: 35
Joined: Wed Jan 24, 2018 9:13 am

Post by alexjaw »

The default i2c library used in the app_usb does not include i2c slave functionality. So, I added lib_i2c, but encountered compiling errors when I tried to use the functions (build log in thread https://www.xcore.com/viewtopic.php?p=32388#p32388.)

Probably we will skip the idea to have app_usb asking for clock frequencies and attach a separate pll that xmos will control directly (as i2c master).
Post Reply