Hi team,
I help customers send a post.
"I am working on CAN Interrupts of TMS570LS1224. I want to generate a sine wave signal of CAN Raw data. I tried by modifying the code of CAN Interrupt, but i couldnt get output, can you pleae help me by telling where i am goin wrong? This is the code below i am using:
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "can.h"
#include "esm.h"
#include "sys_core.h"
#include "sci.h"
#include "stdio.h"
#include "math.h"
#define D_COUNT 8
uint32 cnt=0, error =0, tx_done =0;
uint8 tx_data[D_COUNT][8] = {0};
uint8 rx_data[D_COUNT][8] = {0};
uint8 *tx_ptr = &tx_data[0][0];
uint8 *rx_ptr = &rx_data[0][0];
uint8 *dptr=0;
uint32 cnt1 = 0;
int x=0;
int y=0;
float i=0;
int j=0;
float a[600];
void dumpSomeData();
void dumpSomeData1();
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
/* enable irq interrupt in Cortex R4 */
_enable_interrupt_();
// sciInit();
//sciSend(scilinREG,18,(unsigned char*)"SCI initialized.\r\n");
/** - writing a random data in RAM - to transmit */
//dumpSomeData();
dumpSomeData1();
/** - configuring CAN1 MB1,Msg ID-1 to transmit and CAN2 MB1 to receive */
canInit();
/** - enabling error interrupts */
canEnableErrorNotification(canREG1);
canEnableErrorNotification(canREG2);
/** - starting transmission */
for(cnt1=0;cnt1<D_COUNT;cnt1++)
{
int cnt1 = 0;
canTransmit(canREG1, canMESSAGE_BOX1, tx_ptr); /* transmitting 8 different chunks 1 by 1 */
while(tx_done == 0){
// if (++cnt1 == 100){
// sciSend(scilinREG,18,(unsigned char*)"Could not transmit.\r\n");
// break;
// }
}; /* .... wait until transmit request is through */
for (x=1;x<200;x++)
{
for(y=0;y<200;y++){};
}
tx_done=1;
tx_ptr +=8; /* next chunk ....*/
}
/** - check the received data with the one that was transmitted */
tx_ptr = &tx_data[0][0];
rx_ptr = &rx_data[0][0];
for(cnt=0;cnt<63;cnt++)
{
if(*tx_ptr++ != *rx_ptr++)
{
error++; /* data error */
}
}
while(1){}; /* wait forever after tx-rx complete. */
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
/* writing some data to ram */
void dumpSomeData()
{
uint32 tmp = 0x11;
cnt = (D_COUNT*8)-1;
dptr = &tx_data[0][0];
*dptr = tmp;
while(cnt--)
{
tmp = *dptr++;
*dptr = tmp + 0x11;
}
}
void dumpSomeData1()
{
uint32 tmp;
cnt = (D_COUNT*8)-1;
*dptr = tmp;
for(i=0;i<40;)
{
*dptr=10*sin(2*3.14*50*i);
dptr = &tx_data[0][0];
j++;
i=i+1.5;
}
}
This is how i am getting output:
"
Thank you for your help.
Best regards,