Other Parts Discussed in Thread: HALCOGEN
Tool/software: Code Composer Studio
Hi together, I have some trouble with the sfety lib example from halcogen.
I followed the instructions and get a correct build. After I load it to the mcu, my programm starts. But after the programm try to start the self test of the first CAN-Controller, it gets a negative Response from the function calls and ends in the following while(1) instruction.
if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_1BIT, SL_DCAN1) == false)
{
while(1); // here the progamm ends
}
I had a look into the function and figuered out, what is the Problem. The function is defined in sl_selftest.c. There the programm checks, if the INIT-BIT in the CANREG1->CTL Register is set. If it is, then the function Returns false. In my case, the bit is set, so I end in the while(1) instruction above.
if((boolean)sl_canREG)
{
/*SAFETYMCUSW 134 S MR: 12.2 <APPROVED> Comment_5*/
if ((uint32)CAN_INIT_BIT == (sl_canREG->CTL & CAN_INIT_BIT)) {
SL_Log_Error(FUNC_ID_ST_CAN, ERR_TYPE_ENTRY_CON, 3u);
retVal = FALSE;
return retVal;
}
The Problem is, that the bit is always set after a restart of the mcu. And there is no instruction in before, which will reset the bit. There is a function before, which shoul initilize the CAN_RAM.
SL_Init_Memory( RAMTYPE_DMA_RAM |
RAMTYPE_NHET1 |
RAMTYPE_HET_TU1 |
RAMTYPE_NHET2 |
RAMTYPE_HET_TU2 |
RAMTYPE_DCAN1_RAM |
RAMTYPE_DCAN2_RAM |
RAMTYPE_DCAN3_RAM |
RAMTYPE_DCAN4_RAM |
RAMTYPE_MIBSPI1_RAM |
RAMTYPE_MIBSPI2_RAM |
RAMTYPE_MIBSPI3_RAM |
RAMTYPE_MIBSPI4_RAM |
RAMTYPE_MIBSPI5_RAM |
RAMTYPE_MIBADC1_RAM |
RAMTYPE_MIBADC2_RAM );
But this function do not clear the Control Register of the CAN-Module. So I added 4 extra lines, where I manually reset the bits for all CAN-REGs, before I start with the self test.
canREG1->CTL =(0 << 0);
canREG2->CTL =(0 << 0);
canREG3->CTL =(0 << 0);
canREG4->CTL =(0 << 0);
After this add, my programm runs without any Problems. I don't know, if it is the right way. Can somebody confirm it, please?
In my opinion, the test of the bit have a special reason, which I do not know and I manupulate the programm, which is not a good kind. So maybe sth. is wrong with my Settings? Or why the bit is always set, when I start the selftest function?
Thanks very much in advance.