2021-04-27 05:17 AM
Hello,
I am working on a SPC560P Discovery Board.
I have imported test application 'SPC560Pxx RLACAN Test Application for Discovery' for FlexCAN testing. In this FlexCAN0 is used in loop back mode and it is working.
But after disabling loop back mode,I cant see any data on the CAN_TX pin with scope.
I configured the:
After i start the application the program gets stuck in the transmit while loop:
Its seems like that thecan_lld_is_tx_empty function returns FALSE and it breaks the can_lld_transmit function.
Is the mailbox needs any additional configuration or I configured the CAN clock incorrectly?
Thanks for your help and sorry for the the lot questions but I am new to 32bit controller programming.
Regards,
Saravanan Mariyappan
Solved! Go to Solution.
2021-04-28 05:29 AM
we have been checked the Baud rate for the Both is 1 mb/s and both are little endian only verified with help of datasheet of SPC and STM32 controllers
2021-04-28 09:22 PM
Please verify the picture for the Baud rate of the Both the Boards
2021-04-28 11:16 PM
Hi Saravan,
the baudrate seems on Pictus seems to be correctly configured to 1M. So, the communication between the 2 boards should be correctly executed. Let me suggest also to try to reduce the baudrate on both boards or, if you have available a second Pictus discovery, to try the communication between the 2 Pictus.
Regards,
Luigi
2021-04-29 06:00 AM
Hi sir,
Just to highlight again, Can u explain me why this code is stucked in the function can_lld_is_tx_empty function returns FALSE and it breaks the can_lld_transmit function. why it happening
or
Normally When this function will return (can_lld_is_tx_empty function) FALSE and it breaks the can_lld_transmit function.
2021-04-29 06:03 AM
Hi sir,
Just to highlight again, Can u explain me why this code is stucked in the function can_lld_is_tx_empty function returns FALSE and it breaks the can_lld_transmit function. why it happening
or
Normally When this function will return (can_lld_is_tx_empty function) FALSE and it breaks the can_lld_transmit function.
From my understanding
2021-04-29 10:17 PM
Hi,
in the project that I shared, the can_lld_transmit is invoked within a while cycle that try to transmit a packed using the mailbox 1. If the packet is not received by the receiver (STM32), the mailbox will not return free and, on the next call of the can_lld_transmit, the function can_lld_is_tx_empy will return FALSE. In other words, if the receiver doesn't receive the CAN packet, the next one cannot be sent on the same mailbox. The possible issues can be 1. the pin and CAN configuration (from the Pictus Discovery side, I have provided you a project that included these configuration, so the issue could be on the STM32 side) 2. the baudrate 3. the endianess (as already specified, the PPC is a big endian architecture).
Regards,
Luigi
2021-04-30 12:34 AM
Hi sir Thanks for the reply,
2021-04-30 01:38 AM
Hi Saravanan,
as explained before, the aim of the project for Pictus Discovery that I shared before is to send some CAN packets through the Pictus CAN transceiver to another board (based on another PowerPC device of the same Pictus family with the same CAN low level driver) that receives the CAN packets from Pictus, converts them in serial packets and transfers them via serial to the host. On the host we have a tool that shows the packets received via serial. In this way we can control the CAN packets sent by the Pictus directly on the host.
Now, the firmware on the second board that receives the CAN packets from the Pictus Discovery uses the same CAN low level driver used by the Pictus to trasmit the CAN packets. Since the baudrate of the CAN on Pictus Discovery is 1M, the same baudrate is configured also on this second board (please, see the configuration in attachment).
Moreover, the code used to receive the CAN packets from the Pictus Discovery is the following:
void flexcan1000_Fifo_RX(CANDriver *canp, CANRxFrame crfp) {
data_send(crfp);
(void) canp;
}
void data_send(CANRxFrame crfp) {
uint8_t buffer[18];
uint8_t i;
for (i=0;i<18;i++){
buffer[i] = 0x00;
}
*((uint16_t *)buffer) = crfp.TIME;
buffer[2] = crfp.LENGTH;
buffer[3] = crfp.RTR;
buffer[4] = crfp.TYPE;
//buffer += 5;
*((uint32_t *)&buffer[5]) = crfp.ID;
*((uint32_t *)&buffer[9]) = crfp.data32[0];
*((uint32_t *)&buffer[13]) = crfp.data32[1];
buffer[17] = 0xA4;
sd_lld_write(&SD1, buffer, 18);
}
int main(void) {
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
/* Enable Interrupts */
irqIsrEnable();
/* Start Serial Driver */
sd_lld_start(&SD1, NULL);
/* Start CAN Driver */
can_lld_start(&CAND1, &can_config_flexcan1000);
/* Application main loop.*/
for (;;) {
}
}
where flexcan1000_Fifo_RX is the RX callback of the CAN low level driver used to receive the packets from the Pictus Discovery.
Finally, the CAN low level driver used on the second board has been a little bit patched to receive all the packets sent by the Pictus. You can find it in attachment.
Regards,
Luigi
2022-02-21 03:53 AM
Dear Luigi,
I think we are facing the same issue. Where can I find the zip file you refer?
Thank you very much,
José
2022-02-21 04:26 AM