Hi I am trying to read a I2C slave device using PE SDK and MQX-lite. This would seemingly be easy. Even with very little, or more correct no code written by me, the program crashes. Here is what I have done:
-Installed Kinetis Design Studio 3.0.0
-Installed PE SW updates to add support for the MKL27Zxxx family
-Installed Kinetis Software Development Kit 1.3.0
-Run “Install new Software …” from PE to add SDK into PE (C:\Freescale\KSDK_1.3.0\tools\eclipse_update\KSDK_1.3.0_Eclipse_Update.zip)
-Add one output I/O pin. This pin will be used to drive a single LED
-Add OS to the project (MQX lite)
-Add one task and writing a few lines of code for blinking the LED once every second
This works fine and the LED is blinking.
Then I modify the program by adding one I2C master and enable Auto Initialization. I do not add any code to use the I2C master yet.
I recompile the code and start debugging the program. The program crashes and it seems like there are problems during task scheduling. Please note that I have not written any code myself for I2C initialization or usage. All code related to I2C are auto generated based on my settings in PE.
I actually do not think this has anything to do with I2C. It just happens to be I2C that’s the first interrupt driven driver that I am using in my first SDK+PE+MQX-lite project. I believe that the problem are somehow related to interrupts and MQX-lite.
Is there anything that I have forgot during PE setup that can explain this?
Hello Olav,
Could you please send your project to us , we will test and check it on our side .
BR
Alice
Hello Alice
Thanks for a very quick response. Attached is the complete workspace. It contains only one project.
The MCU is : MKL27Z256 in 64 pin QFP
LED0 is connected to output pin on PTA5
I2C are connected to I2C0 on PTB0 and PTB1
Only one task (in addition to idle task) LED_Main() the 4 lines in this task is the only one I have written, the rest is auto generated. As the program is now it crashes. If you remove "Auto initialization" of the I2C master, the program will run.
Hello Olav,
I test on my side , it also have the same question . And i also add SPI component to test , it is the same.
And when create one KSDK project without MQX, it can work well , so i think it maybe the reason of MQX.
I will ask the mqx expert about how to solve it , and i will tell you .ASAP.
BR
Alice
My conclusion to this problem is that MQX-lite does not work at least for my combination of KDS, SDK and MCU. I changed to full MQX and all problems disappeared.
MQX-lite crashes deep inside the task scheduler during start-up. This also happens with only auto generated code and 3 user tasks. I was actually able to force the MQX-lite application to start by single stepping through the scheduler. Running at full speed however it crashes.
Hello Alice
Any news?
We also have a different board using an MKL17Z256 MCU. I have the exact same problems on this board/MCU. When I2C is auto initialized the program craches during MQX-lite startup.
This problem however have a simple workaround. Perform the initialization manually.
A mutch more severe problem is that I cant have more than 2 user tasks! Adding the third task craches MQX-lite during startup!
Hello Alice
My workaround is to not use the auto initialization called from the file cpu.c, but instead copy the initialization code into my code/task. This seems to work. But of course the auto initialization method should work also.
BR
Olav
Hello Alice
Seems like the workaround have its limitations. I added a new MQX-lite task (I then have a total of 2 + idle task) and it starts to go wrong again.
From the dispatch.S file:
ASM_LABEL(return_via_pendsv)
// load SCB address to r0
ldr r0, =0xE000ED00
//set PendSV flag
ldr r1, =0x10000000 /* PENDSVSET */
str r1, [r0, #4] /* 0xE000ED04 */
//enable interrupts to execute PendSV handler
cpsie i
//this point normally shall not be reached - PendSV executes immediatelly and never returns back here
b .
Execution actually reached the line with b. during OS startup, and before my code get executed. There is obviously something very wrong here.
If I delete the new task, it starts working again.
To me it seems like there are problems related to interrupt handling. I believe this problem basically has the same cause as the original problem.
BR
Olav
Hello Alice
Any progress regarding the MQX-lite+PE problems?
If I add more than 2 user tasks then the program crashes deep inside MQX-lite scheduling.