How to choose I2C (or SPI) peripheral to use?

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

How to choose I2C (or SPI) peripheral to use?

跳至解决方案
1,706 次查看
gsanchez
Contributor III

Hello friends, I have this question today. Observing the Kinetis K60 datasheet with I count (MK60DX256ZVLQ10), I can see that it have two pairs of pins with support for "I2C0" peripheral, that is:

pin 81: I2C0_SCL (ALT2)

pin 82: I2C0_SDA (ALT2)

pin 83: I2C0_SCL (ALT2)

pin 84: I2C0_SDA (ALT2)

I'm using MQX 3.8.1 with a customized board with the MCU descripted before. My question is very simple: Using MQX, with the BSP, formatted IO , and "fopen" function, how do I indicate to MQX which one of two pair of pins I will use?

This question can apply to SPI peripheral...

标记 (5)
0 项奖励
回复
1 解答
1,413 次查看
Martin_
NXP Employee
NXP Employee

The mapping of internal MCU signals to MCU pins is BSP dependent. The source file name is init_gpio.c:

c:\Freescale\Freescale MQX 3.8\mqx\source\bsp\twrk60d100m\init_gpio.c

there is function _bsp_i2c_io_init() which is called by fopen() of an i2c io device.

so you have two options, either your way, but then I recommend to empty the _bsp_i2c_io_init(), so that you don't end up on the functions selected on both muxes. or you can modify the BSP init_gpio.c to meet your hardware. 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,413 次查看
gsanchez
Contributor III

Ok I have tried and I do the following:

Open the pins that I want to use as LWGPIO and set functionality to (2). Not set direction and initial value. This must be do before to open I2C peripheral.

This work fine.

Please let me know if this is the correct way to do this.

Thanks.

1,414 次查看
Martin_
NXP Employee
NXP Employee

The mapping of internal MCU signals to MCU pins is BSP dependent. The source file name is init_gpio.c:

c:\Freescale\Freescale MQX 3.8\mqx\source\bsp\twrk60d100m\init_gpio.c

there is function _bsp_i2c_io_init() which is called by fopen() of an i2c io device.

so you have two options, either your way, but then I recommend to empty the _bsp_i2c_io_init(), so that you don't end up on the functions selected on both muxes. or you can modify the BSP init_gpio.c to meet your hardware. 

0 项奖励
回复
1,413 次查看
gsanchez
Contributor III

Thanks for your answer Martin! That is the exact place were to find the definitions.

As remark, to the next releases, Freescale can put a "simple way" to define it... Using "user_config.h" for example:

#if (BSPCFG_ENABLE_I2C0 = 1)

#define I2C0_SDA_PIN     PTD9

#define I2C0_SCL_PIN     PTD8

#endif

Kind regards,

0 项奖励
回复