When I am searching for bootloader program for S32K144 I came across this following code.
While I am trying to debug the S32K144_FOTA_Gateway I got struct in the following line.
while(0 == (CAN0->IFLAG1 >> CAN_TXbuffer_ptr->MB) & 1 ); //Line No:234 in S32K144_FOTA_Gateway>src>FlexCan.C
Also whether following code can be used for can 2.0 instead of using CAN FD?
We have connected the Vehicle Spy on the CAN Bus to understand the CAN Communication. But we are not getting the data on the CAN bus. It's getting stuck in the FlexCAN0_transmit while loop.
Could you let us know why it is getting stuck in the while Loop. What might be wrong ?
We are testing this on our custom hardware with the same pinout used in the s32k evek PTE4 & 5 for CAN TX / RX
When checking by an oscilloscope - can you see the signal on TX pin and also on CANH and CANL?
Regards,
Lukas
Hi,
We can't observe CANH and CANL signals through oscilloscope. Actually could you please suggest ways to test CAN bus and what are the configurations needed for CAN bus to work.
Checking of TX and CANH-CANL signals is a key point at the beginning. It's necessary to check if the transceiver is up and running. We can test whatever we want but if there's no signal, it's just wasting of time.
Regards,
Lukas
Hi,
The CAN Part is working with our custom hardware when we generate the code using freemaster. But it is not working with the example bootloader gateway code . The difference what we are seeing on this code are the clock initialization API. Could you please help us what is the difference between these API calls.
In Freemaster
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
In Example Bootloader Gateway Code, we are seeing the clock initialization with this API
SOSC_init_8MHz(); /* Initialize system oscillator for 8 MHz xtal */
SPLL_init_160MHz(); /* Initialize SPLL to 160 MHz with 8 MHz SOSC */
NormalRUNmode_80MHz(); /* Init clocks: 80 MHz sysclk & core, 40 MHz bus, 20 MHz flash */
LMEM->PCCCR = 0x85000001; /* Invalidate cache & enable write buffer, cache */
Hi,
that's SDK code and baremetal code. You need to check in the SDK if you have the same clock settings as in the baremetal code. The SDK configuration is not visible in that piece of code, you need to check this in Processor Expert.
Regards,
Lukas
Hi,
I have attached Clock configuration and PE file of SDK code below. Also I have compared the clock configurations between SDK code and BareMetal code. I have observe changes in normal run mode frequency. I have changed that configurations for normal run mode but still it get struck at the same while loop
while(0 == ( (CAN0->IFLAG1 >> CAN_TXbuffer_ptr->MB) & 1 ));
I have attached files for baremetal code and SDk also. Could please tell what are the changes we need to make.
Yes the second board is connected to CAN. Using this CAN module we have able to receive messages for other projects. But I am not able to transmit message through CAN from second board using this FOTA_gateway program. Still it is getting struct at this following while statement.
while(0 == (CAN0->IFLAG1 >> CAN_TXbuffer_ptr->MB) & 1 ); //Line No:234 in S32K144_FOTA_Gateway>src>FlexCan.C
Do you use S32K144-EVB? There's in-built CAN transceiver in SBC UJA1169, so the board needs to be supplied by external 12V, not by USB only. Is the SBC still in forced mode? Or did you execute this example which switch it to normal mode?
c:\NXP\S32DS.3.4\S32DS\software\S32SDK_S32K1XX_RTM_4.0.2\examples\S32K144\driver_examples\communication\sbc_uja116x\
If it is in normal mode, the CAN transceiver in SBC needs to be enabled via SPI. Or it's necessary to switch back to forced mode.
I would try to check by an oscilloscope if you can see the CAN signals on TX-RX and CANH-CANL.
Regards,
Lukas
Hi Aparna,
is the second board connected via CAN? This is typical behavior - second board is either not connected or there's some wiring issue...
Yes, the code can be updated to use standard CAN.
Regards,
Lukas