Hello Team,
I'm working with IWRL6432 i have initialized mcan for tx and rx messages. Once after i complete the communication process i want to de-initialize the CAN. How can i do it. Thanks
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello Team,
I'm working with IWRL6432 i have initialized mcan for tx and rx messages. Once after i complete the communication process i want to de-initialize the CAN. How can i do it. Thanks
Hey Madhusudhan,
This will depend on what you define as "de-initialized" for CAN, but I would interpret this as powering down the CAN transceiver. You would need to initiate a clock stop request using MCAN_addClockStopRequest to set the CCCR.CSR field to 1. The CAN transceiver should wait for any pending transfer requests, then CCCR.INIT should be set to 1, and finally CCCR.CSA (Clock Stop Acknowledge) should be set to 1. You can get the status of the CCCR.CSA field by calling MCAN_getClkStopAck which will return either 0 - no clock stop acknowledged - or 1 - clock stop acknowledged. From here, the clocks to the CAN transceiver can be disabled using the following code:
PRCMPeripheralClkEnable(Power_module.dbRecords[0], PRCM_GATE_CLK_DISABLE);
CSL_REG32_FINS((CSL_APP_RCM_U_BASE + CSL_APP_RCM_IPCFGCLKGATE1), APP_RCM_IPCFGCLKGATE1_IPCFGCLKGATE1_APP_CAN, PRCM_GATE_CLK_DISABLE);
Most of these steps are outlined in Section 12.4.4.8 Power Down (Sleep) Mode of the xWRLx432 Technical Reference Manual which also includes steps on powering up the device - essentially just repeat the disable steps in reverse and using enable macros instead for the clocks.
Hopefully this gives you a rough idea of how to approach this, but let me know if there's anything you need clarified.
Regards,
Kristien
Hello Kristien,
Thanks for the immediate response. I have actually integrated CAN for SBL code available at sdk 05_03_00_02. Communication is setup and it is able to download the complete appImage with no issues. I have also read the ram area to check whether there's any packet loss, i can confirm i have received all the bytes after reading the RAM area. But after bootload function is started is see output as No Valid image. I'm using Hello World cpp application. along with this i have more points to add like, while i use the can integrated code to load with UART even now it will download properly but it does not boot. However, if i comment the CAN Init part. it works fine. it will load the application when CAN Init part is commented. i exactly don't know why is it not booting properly when CAN Init is done. So only i asked the above question so after communication is completed i want to de-init the CAN and try to boot and check whether it works. Or do you have any other suggestions to overcome the issue. Thanks
Hey Madhusudhan,
Just to clarify, are you able to download the image over CAN, downloading the image over UART, or using the backup application image flashed to the device? You mentioned that removing your CAN initialization allowed booting to occur, so that seems to imply you are either downloading an image over UART or using the backup image.
What is your CAN init function or code? I'm assuming you are using the App_mcanConfig function as an initialization function since you mentioned in a previous thread that you were using the MCAN external read and write example from the SDK. I find it rather odd that the boot would fail depending on whether the CAN module was initialized, but hopefully some of your answers will help me understand what's going on a bit more.
Regards,
Kristien
Hello Kristien,
Yes i'm able to downlaod appImage via CAN. Commenting CAN_Init part and then i download appImage via UART.
Can_Init Function code:
Yes i'm using app_mcanConfig function i.e.
void mcan_init(void *args)
{
int32_t status = SystemP_SUCCESS;
HwiP_Params hwiPrms;
uint32_t bufNum = 0U;
DebugP_assert(SystemP_SUCCESS == status);
/* Register interrupt */
HwiP_Params_init(&hwiPrms);
hwiPrms.intNum = APP_MCAN_INTR_NUM;
hwiPrms.callback = &App_mcanIntrISR;
status = HwiP_construct(&gMcanHwiObject, &hwiPrms);
/* Assign MCAN instance address */
gMcanBaseAddr = (uint32_t) AddrTranslateP_getLocalAddr(APP_MCAN_BASE_ADDR);
SBL_printf("canBaseaddr: %d", gMcanBaseAddr);
/* Configure MCAN module, Enable External LoopBack Mode */
App_mcanConfig(APP_MCAN_LOOPBACK_MODE_DISABLE);
SBL_printf("Config done!");
/* Enable Interrupts */
App_mcanEnableIntr();
SBL_printf("Intr enabled");
/* Select buffer number, 32 buffers available */
bufNum = 0U;
/* Enable Transmission interrupt for the selected buf num,
* If FIFO is used, then need to send FIFO start index until FIFO count */
status = MCAN_txBufTransIntrEnable(gMcanBaseAddr, bufNum, (uint32_t)TRUE);
DebugP_assert(status == CSL_PASS);
return;
}
Here is the CAN Init Code, where i enable interputs assign mcan Instance address. if i comment out gMcanBaseAddr = (uint32_t) AddrTranslateP_getLocalAddr(APP_MCAN_BASE_ADDR); it works well. On the parser end, when i comment out CAN init i get the First packet address different and if i init the CAN then the address will be different. Idk why is it happening that way.
After download the image if CAN is not initiated, In bootload_qpsi method, it will loop through all the blocks. However if i init the CAN its failed to loop through all the blocks.
Flash_read(gFlashHandle[CONFIG_FLASH0], w_metaimageOffset + w_index, p_loadBuff, M_READ_BUFFER_SIZE);
SBL_printf("First Packet: %d", *p_loadBuff);
/*!
* Since we need to get metaimage info, wait for the transfer to
* complete before staring the next read
*/
bootload_switchBuffer(&p_loadBuff, &p_parseBuff);
/*!
* Parse the first chunk
*/
parser_buffMgmt(p_parseBuff, M_READ_BUFFER_SIZE, 0U, M_PARSER_INTERFACE_QSPI);
Untill here both if i Init Can or not. Progrom performs same way and provide the same results. However, after this
for (w_loopCount = 1U; w_loopCount < w_numBlocks; w_loopCount++)
{
if (w_loopCount == 1U)
{
Flash_read(gFlashHandle[CONFIG_FLASH0], w_metaimageOffset + w_index, p_loadBuff, M_READ_BUFFER_SIZE);
SBL_printf("Buffer size: %d", M_READ_BUFFER_SIZE);
bootload_switchBuffer(&p_loadBuff, &p_parseBuff);
w_index += M_READ_BUFFER_SIZE;
}
else
{
Flash_read(gFlashHandle[CONFIG_FLASH0], w_metaimageOffset + w_index, p_loadBuff, M_READ_BUFFER_SIZE);
parser_buffMgmt(p_parseBuff, M_READ_BUFFER_SIZE, 0U, M_PARSER_INTERFACE_QSPI);
bootload_switchBuffer(&p_loadBuff, &p_parseBuff);
w_index += M_READ_BUFFER_SIZE;
}
if (t_ParserCtx.c_ParserState == M_PARSER_BUFFER_PARSER_COMPLETED)
{
break;
}
In the above loop it will work fine for If condition, when it enters the else condition now it has to directly go to case M_PARSER_BUFFER_PARSER_RPRC_DWLD from parser.c file. However it will again go to case M_PARSER_BUFFER_PARSER_STATE_IDLE. and stop the loop with updating information parser is completed. This is where the problem is occurring. Do u have any suggestions why am i facing this problem. thanks
Hey Madhusudhan,
Thank you for all the information you provided! I will need some extra time to look over all this, but I will get back to you by next Monday.
Regards,
Kristien
Hey Madhusudhan,
No problem! I'll get back to you as soon as I can.
Regards,
Kristien
Hey Madhusudhan,
Three more quick questions: What version of the SDK are using with this project? Are you using the FreeRTOS or noRTOS version of Hello World? Did you change the flash address downloaded to?
If you are using the FreeRTOS Hello World appimage, I would check to see if using the noRTOS version works. Depending on the SDK version, there is an issue with the SBL example when loading FreeRTOS appimages that cause the application to crash.
Regards,
Kristien
Hello Kristien,
SDK version : 5_03_00_02
Nortos - Hello World Cpp
I did not change any Flash address i have kept everything same as it is from the SBL code. To give you more brief about the situation when i download the Nortos hello world app image via UART commenting Mcan_init code it will work fine. It will load the image. When i use the same code and initiate Mcan it will not boot, it considers as No Valid image like mentioned in my last question it will not loop through the parser code.
Hello Kristien,
I'm printing the debug statements here are some of it for more clarification on the situation I'm facing:
Below is the code inside the bootload qpsi file, where it will read the first packet information.
Flash_read(gFlashHandle[CONFIG_FLASH0], w_metaimageOffset + w_index, p_loadBuff, M_READ_BUFFER_SIZE);
SBL_printf("First Packet: %d", *p_loadBuff);
bootload_switchBuffer(&p_loadBuff, &p_parseBuff);
/*!
* Parse the first chunk
*/
parser_buffMgmt(p_parseBuff, M_READ_BUFFER_SIZE, 0U, M_PARSER_INTERFACE_QSPI);
send the address of the packet read to parser_buffMgmt function.
Debug message with Mcan_init and Without Mcan_int its same:
First Packet: 77
First Packet: 77
void parser_buffMgmt(uint8_t* p_parseBuff, uint32_t w_bufflen, uint8_t c_islastBuff,
uint8_t c_intfType)
{
if (c_intfType == M_PARSER_INTERFACE_QSPI)
{
SBL_printf("buffmgmt redptr: %d", p_parseBuff);
Reading out the address it has received, when Mcan_init is done i get a different address print and no Mcan_init i get a different address:
Debug messages:
buffmgmt redptr: 4761376 --> No Mcan_init
buffmgmt redptr: 4764608 --> Mcan Init is done.
Hello Kristien,
t_ParserCtx.c_ParserState this particular struct variable is not volatile. So i was facing this issue. it was not loading with the latest value hence parsing was being failed. as i modified it to volatile it works fine now, application is being booted up. i have a question like now making this struct variable has volatile. Do i have to take care of something else in the code. Does this affect any other part of the code. Thanks for all the support
Hey Madhusudhan,
I'm glad you were able to identify the root cause of this issue and resolve it. Setting the parserState field to volatile should have no impact on the rest of the code. If this has completely resolved the issue, please mark this reply as resolved.
Regards,
Kristien