How to access a global variable in a SPI thread?

If you have a simple question and just want an answer.
Ed111
Newbie
Posts: 1
Joined: Fri Aug 07, 2015 5:57 pm

How to access a global variable in a SPI thread?

Post by Ed111 »

Hello everyone.

I'm currently attempting to access a global variable in a asynchronous SPI thread using the "GET_SHARED_GLOBAL(volume,vol_value)" to control a volume chip vai SPI but have seemed to fall into a continuios loop without much progress. I understand that different cores cant share memory normally without using pointers. I have two threads that work great with pointers and have no problems accessing a variable but for some odd reason, when using the GET_SHARED_GLOBAL(volume,vol_value) in the SPI thread,  the vol_value does not change when in fact, it really does..

Is anyone familiar with sharing global variables on a SPI thread? Ive implemented the asynchrounsous SPI function from the AN00160_using_SPI_master. The SPI thread works well on its own but my main objective is to trigger the SPI through a global variable when a user changes the volume.

Any hints will be greatly appreciated!

Thanks!

Ed 

User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1164
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Trying to share memory particularly in SPI makes no difference - an access to memory does not depend on what the surround code does.

What may make a difference is what tile your tasks are placed on. If SPI is on a different tile, then shared memory operations will not work, because  there is no physical shared memory between tiles. In this case, the only way to get a message across is using interfaces or channels (basically the same thing underneath in most cases when going cross tile).

Please check to ensure both sides of the memory sharing reside on the same tile (on tile[n]: in the par{})

 

 

Engineer at XMOS