Kinetis I2C MQX code

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Kinetis I2C MQX code

跳至解决方案
3,396 次查看
ERussell
Contributor IV

I am working with the Kinetis TWR-K60N512 kit and am trying to get some i2c code running. I am using CW10. I can run the i2c demo in the example code in the rev_1_4 folder from Freescale with no problem. This example doesn't use MQX.

 

However when I try to use MQX,  I get an unhandled interrupt  in the i2c task even though the task is using polled mode and the i2c interrupt is disabled in the bsp project. I started with the pe_demo_twrk60n512 example project (from the pe_demo project in the MQX 3.7 folder), modified the bsp_twrk60n512_pe project to add the i2c component, recompiled all the libraries, and added the i2c code as a separate task. I disabled all other tasks except the led task which still runs fine. The i2c task starts up but is aborted as soon as the unhandled interrupt is encountered. I can look at the i2c registers and verify that the interrupt is not enabled. I don't know what the source of the interrupt is.

 

I have also tried using the PE generated code as outlined in the help for the i2c component with my own external i2c peripheral (using I2C0) with the same result. The unhandled interrupt doesn't always occur at the same place in the code. And looking at the i2c communication on a scope hasn't revealed any errors. I installed a task exception handler using _task_set_exception_handler() and print out the exception number that is passed in. This value is always 3.

 

Any help would be greatly appreciated!

 

1 解答
1,638 次查看
marek_vinkler
NXP Employee
NXP Employee

Hi,

 

Here is Processor Expert I2C demo application with MQX for TWR-MK60. There are two zip files. One with MK60 BSP (with integrated Processor Expert project) and the second one with demo application using Processor Expert I2C component from BSP. Just put BSP into MQX proper location, build BSP and demo application. Demo application reads data from on-board accelerometer. Feel free to contact me if any problem.

 

Marek V.

在原帖中查看解决方案

0 项奖励
回复
8 回复数
1,638 次查看
anthony_huereca
NXP Employee
NXP Employee

I can't speak for the PE questions, but MQX already has an I2C driver, so using Processor Expert isn't required.

 

For examples, look at C:\Program Files\Freescale\Freescale MQX 3.7\mqx\examples\i2c

 

Or look at the Kinetis Quick Start Demo code, specifically the Accel_Task.c file which sets up and reads the I2C accelerometer part on the K60 Tower board.

 

-amh

0 项奖励
回复
1,638 次查看
ERussell
Contributor IV

I do like PE and would like to use it if possible.

 

I did try the Kinetis Quick Start Demo which worked just fine. I didn't realize there was a quick start for MQX 3.7 using CW10 - I had only tried the older version for MQX 3.6.2 using IAR.

 

I haven't been able to determine what the difference is between running with PE and MQX versus MQX alone for the i2c code - BUT I was able to run my program (based on the pe_demo) with my external i2c peripheral by adding a 1 msec delay after the call to the PE routine I2C_Main(). This would probably be the equivalent to the MQX call to fflush(). I2C_Main() is called while waiting for the transmission to complete and sets the appropriate event upon completion.

 

My concern is whether adding a delay is a trustable solution and why it is necessary at all. I haven't changed anything else about my code.

 

Any thoughts?

0 项奖励
回复
1,638 次查看
marek_vinkler
NXP Employee
NXP Employee

I'm glad to hear that you would like to use Processor Expert within MQX. We will prepare I2C example in Processor Expert for you. You can use it as a starting point in your application. It will be prepared at beginning of the next week due to hollidays in Brno, Czech Republic.

 

Marek V.

0 项奖励
回复
1,638 次查看
ERussell
Contributor IV

That sounds great. I look forward to seeing it.

 

Thanks.

0 项奖励
回复
1,639 次查看
marek_vinkler
NXP Employee
NXP Employee

Hi,

 

Here is Processor Expert I2C demo application with MQX for TWR-MK60. There are two zip files. One with MK60 BSP (with integrated Processor Expert project) and the second one with demo application using Processor Expert I2C component from BSP. Just put BSP into MQX proper location, build BSP and demo application. Demo application reads data from on-board accelerometer. Feel free to contact me if any problem.

 

Marek V.

0 项奖励
回复
1,638 次查看
abidesmail
Contributor II

Hi,

Where can I download this sample application.

Thanks,

Abid

0 项奖励
回复
1,638 次查看
richardtseng
Contributor I

Where can I download the two zip files ?

Thanks,

Richard

0 项奖励
回复
1,638 次查看
ERussell
Contributor IV

Thank you for the demo. I was able to get it running. It uses an interrupt driven interface and I was wondering if you could provide a polled version as well?

 

Also I tried using breakpoints and found that they caused a transmission timeout condition, even when only one breakpoint was used (hardware or software) and was placed before a call to ReadACCRegs().  Is it not possible to use breakpoints while debugging when using the Timer?

0 项奖励
回复