i have a tms57004 board. i have been trying to write a code from communication between 2 such boards via spi. however the code i have written does not seem to work.
code for the master-
#include"spi.h"
#include "sys_common.h"
uint16 x=0x01;
uint16 *transfer=&x;
void initialize(spiDAT1_t *spih)
{
spih->CS_HOLD = TRUE;
spih->WDEL = FALSE;
spih->DFSEL = SPI_FMT_0;
spih->CSNR = 0x00;
}
void main(void)
{
spiInit();
gioInit();
spiDAT1_t dataconfig1_t;
initialize(&dataconfig1_t);
while(1)
{
spiTransmitData(spiREG1,&dataconfig1_t,1,transfer);
}
}
code for the slave-
#include"spi.h"
#include"gio.h"
#include "sys_common.h"
uint16 *receive;
void initialize(spiDAT1_t *spih)
{
spih->CS_HOLD = TRUE;
spih->WDEL = FALSE;
spih->DFSEL = SPI_FMT_0;
spih->CSNR = 0x00;
}
void main(void){
spiInit();
gioInit();
spiDAT1_t dataconfig1_t;
initialize(&dataconfig1_t);
while(1)
{
spiReceiveData(spiREG1,&dataconfig1_t,1,receive);
if(*receive==1)
gioSetBit(gioPORTA,2,1);
}
}
if the data transfer is successful the led at the slave end will glow.
i have uploaded the master code to one board and the slave code to another.
however this does not seem to work.
i think i may also be getting the spi1 SIMO multiplexing wrong.
could someone please tel me how do i correct this...