I am currently trying to implement SPI on an xCore-200 (using the explorer kit), using the async SPI Master as found in the öib_spi(v3.02) provided by xmos.
On trying to add SPI functionality to the project, i got issues with the programm halting right after startup with an ET_ECALL Signal, highlighting lines in spi_asyn.xc. From what i have read, this is caused by pointer/array operations out of bounds.
I have created a smaller project, starting only the spi_master_async() thread and a second thread, that keeps sending an 8 byte array periodically.
Code: Select all
#include "spi.h"
out buffered port:32 p_sclk = on tile[0]: XS1_PORT_1A; // D00
out port p_ss[1] = on tile[0]: {XS1_PORT_1O}; // D38
in buffered port:32 p_miso = on tile[0]: XS1_PORT_1B; // D01
out buffered port:32 p_mosi = on tile[0]: XS1_PORT_1P; // D39
int main(){
interface spi_master_async_if spi_if[1];
par {
on tile[0]: spiTestAppliction(spi_if[0]);
on tile[0]: spi_master_async(spi_if, 1,
p_sclk, p_mosi, p_miso, p_ss, 1,
spiClk0, spiClk1);
}
return 0;
}
Code: Select all
void spiTestAppliction(client interface spi_master_async_if spi_if){
timer t;
unsigned int time;
t :> time;
unsigned char ucaTx[8] = {1,2,3,4,5,6,7,8};
unsigned char ucaRx[8];
unsigned char * movable ucpTx = &ucaTx[0];
unsigned char * movable ucpRx = &ucaRx[0];
while(1){
select{
case t when timerafter(time) :> void:
spi_if.begin_transaction(0, 1000, SPI_MODE_1);
spi_if.init_transfer_array_8(move(ucpTx), move(ucpRx), 8);
break;
case spi_if.transfer_complete():
spi_if.end_transaction(200);
break;
}
}
}
Code: Select all
init_init_transfer_array_8(sclk, mosi, miso, active_mode, cb1, ((uint8_t*movable)buffer_tx)[0]);
Do you have an idea, what is going wrong?
Thanks in advance,
Regards