Hello everyone,
I'm using TMS570LS0432, with 5.4.00091 CCS and Halcogen 03.05.02.
What I'm tyring to achieve is make SPI2 work in slave mode with interrupts (send and receive data of fixed length uint16 type array). Thing should work in polling mode every 1s. Receive data, put it to certain array (maybe do required calculations) and send this data only when next data send occurs (after 1 second).
I'm using SPI3 as master which sends data with "spiTransmitAndReceiveData" function, using RTI interrupts (blinking leds indicate operation of program). I initialize program and enter while(1) loop, the rest should be done in interrupts.
The code is as follows:
#include "sys_common.h"
#include "system.h"
/* USER CODE BEGIN (1) */
#include "spi.h"
#include "gio.h"
#include "rti.h"
#define length 8
uint16 TXbuf[length]={0};
uint16 RXbuf2[length]={0};
spiDAT1_t structure;
spiDAT1_t *pointer;
/* USER CODE END */
/* USER CODE BEGIN (2) */
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */
uint32 i;
pointer=&structure;
for(i=0;i<length;i++) //for filling up with initial data
{
TXbuf[i]=12-i;
}
_enable_IRQ(); //initializations and enables
gioInit();
rtiInit();
spiInit();
rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
rtiResetCounter(rtiCOUNTER_BLOCK0);
rtiStartCounter(rtiCOUNTER_BLOCK0);
spiEnableNotification(spiREG2, spiREG2->INT0);
while(1){ } // endless loop since program runs with real time timer interrupts
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
void rtiNotification(uint32 notification)
{
pointer=&structure;
uint16 i;
gioToggleBit(gioPORTA, 3); //toggling leds to see that program is running
gioToggleBit(gioPORTA, 4);
gioToggleBit(gioPORTA, 6);
spiTransmitAndReceiveData(spiREG3, pointer, length, TXbuf, RXbuf2);
for(i=0;i<length;i++)
{
TXbuf[i]=length+TXbuf[i];
}
}
But the program isn't jumping to interrupts.
The if I enter this line (spiREG2->DAT1=spiREG2->BUF;), before entering while(1) loop (and enter same line in "spi2HighLevelInterrupt" after initializations, before case statement), after sending data, program jumps to interrupt but only once per sending (so in case of 10 member array, I receive last member). This must be related with specific flags, but I'm not sure which ones and how.
1)I'd like to know how to make the program to receive whole array and to send whole array as a responce.
2) What is the difference between "spiTransmitAndReceiveData" and "spiSendAndGetData".
3)I'm interested just in slave mode, and master is just configured for testing purposes.
Regards,
Vytautas