ΣSigmaStudio Ask AI Русский Log in

Send data problems using SC589 CAN

Processors & DSP lululululu Dec 14, 2020 00:00 2 replies Original on forum ↗
Subscribe
lululululu Question
Dec 14, 2020 00:00

I used 'SC589 EZKIT CAN0' to send data to the USB-CAN transceiver in the hope of displaying the received data on the PC side, but failed. But using an oscilloscope detects that the CAN-H and CAN-L pins have outputs, but they keep coming in. In addition, according to The data reported by The CAN_ESR register, "Stuff Bit Error" was displayed.

Here is some of my code:

bool Init_CAN_Port(void)
{

*pREG_CAN0_TIMING = 0x0225; //OCLK 90Mhz bitrate:500Khz

*pREG_CAN1_TIMING = 0x0352;

/* *pREG_CAN0_CLK = 71; 125kHz CAN Clock :: tBIT = 8us
*pREG_CAN1_CLK = 71; 125kHz CAN Clock :: tBIT = 8us */

*pREG_CAN0_CLK = 17;
*pREG_CAN1_CLK = 17;

// ssync();
printf("pREG_CAN0_CLK = %08x pREG_CAN1_TIMING = %08x \n",*pREG_CAN0_CLK,*pREG_CAN0_TIMING);
/*init the CAN mail boxes */

// configure tx mailbox
*pREG_CAN0_MB10_ID0 = 0x0017; //
*pREG_CAN0_MB10_ID1 = (((1 << BITP_CAN_MB_ID1_IDE) & BITM_CAN_MB_ID1_IDE) |
(( 2 >> 16) & BITM_CAN_MB_ID1_EXTID) |
(( 0x005 << BITP_CAN_MB_ID1_BASEID) & BITM_CAN_MB_ID1_BASEID));
*pREG_CAN0_MD1 &= ~(1 << 10);

// configure rx mailbox
*pREG_CAN1_MB10_ID0 = 0x0017; //
*pREG_CAN1_MB10_ID1 = (((1 << BITP_CAN_MB_ID1_IDE) & BITM_CAN_MB_ID1_IDE) |
(( 2 >> 16) & BITM_CAN_MB_ID1_EXTID) |
(( 0x005 << BITP_CAN_MB_ID1_BASEID) & BITM_CAN_MB_ID1_BASEID));
*pREG_CAN1_MD1 |= (1 << 10);

*pREG_CAN0_MC1 |= (1 << 10);
*pREG_CAN1_MC1 |= (1 << 10);
*pREG_CAN1_CTL &= ~BITM_CAN_CTL_CCR; // Exit CAN Configuration Mode (Clear CCR)
while(*pREG_CAN1_STAT & BITM_CAN_STAT_CCA);
*pREG_CAN0_CTL &= ~BITM_CAN_CTL_CCR; // Exit CAN Configuration Mode (Clear CCR)
while(*pREG_CAN0_STAT & BITM_CAN_STAT_CCA);

*pREG_CAN0_DBG |= (1 << 15);
*pREG_CAN0_DBG |= (1 << 4);

return PASSED;

}

void Send_Data(unsigned short *tx)
{

printf("pREG_CAN0_STAT = %08x\n",*pREG_CAN0_STAT);

*pREG_CAN0_MB10_LENGTH = 8;

*pREG_CAN0_MB10_DATA0 = tx[0];

*pREG_CAN0_MB10_DATA1 = tx[1];

*pREG_CAN0_MB10_DATA2 = tx[2];

*pREG_CAN0_MB10_DATA3 = tx[3];

*pREG_CAN0_TRS1 |= (1 << 10); // setting transmitter mail box ID

}

int TEST_CAN(void)
{

int i = 0;
int RetValue = PASSED;
unsigned short TxData[4]={0x1111,0x2222,0x3333,0x4444};
unsigned short RxData[4]={0x0,0x0,0x0,0x0};

/* setup pinmux and softconfig */
test_setup(true);

/* This loop will run only once */
do
{
if(Init_CAN_Port() == FAILED)
{

RetValue = FAILED;
printf("enter fail\n");
break;
}

/* config GPIO to enable CAN0 */
if(CAN1055gpioEnable() == FAILED)
{

RetValue = FAILED;
printf("enter fail\n");
break;
}

}while(0);

if(RetValue != PASSED)
{
test_setup(false);
printf("459\n");
return RetValue;
}

Init_CAN_Interrupts();

// seed the random number generator with something random

srand(RxData[0]);

Send_Data(TxData); // TX the data from CAN0 MB10

while(! ( *pREG_CAN0_TA1 & (1 << 10) )); // Waiting for completion of transmission

printf("tx over\n");
test_setup(false);
return 0;
}

sharc

dsp&processors

ADIApproved Reply
Dec 18, 2020 00:00

Hi,

I understand that you are facing issue in CAN data transfer on ADSP-SC589 Ez-kit. I would suggest you to refer the CAN example code available in the below link. This can be directly run on ADSP-SC573 Ez-kit. However, you can easily port this for ADSP-SC589. Please use this as reference and modify as per your requirement.
https://ez.analog.com/dsp/sharc-processors/adsp-sc5xxadsp-215xx/w/documents/14020/code-example-controller-area-network-can-for-adsp-sc573

Also, there is an CAN example code available in the ADSP-SC5xx Board support package. The BSP file can be downloaded via below link.
http://download.analog.com/tools/EZBoards/SC5xx/Releases/Release_2.0.2/ADI_ADSP-SC5xx_EZ-KIT_Lite-Rel2.0.2.exe

After installing BSP, please navigate as given below.
<Installation directory>:\Analog Devices\ADSP-SC5xx_EZ-KIT_Lite-Rel2.0.2\ADSP-SC5xx_EZ-KIT\Examples\Power_On_Self_Test\common\source\can_test.c

Regards,
Anand Selvaraj.

ADIApproved Reply
Dec 24, 2020 00:00

Hi,

When a transmission completes, the corresponding bits in the transmit request set register (CAN_TRS1) are cleared. Setting the CAN_TRS1 bit associated with a disabled mailbox may result in erroneous behavior. So, can you confirm if the transmission is complete. Can you also check if any errors are reported?

BTW, did you get a chance to test the loopback code at your end?

Regards,
Anand Selvaraj.