Hi,
I have a custom board with K65 with a 24MHz external oscillator (16MHz in K65 schematics). Initially, the code was not even loading because of the oscillator mismatch. Then came UART baud rate issue, which was fixed by doubling the expected baud rate in twrk65f180m.h header file in bsp. Now I am trying to interface a I2C peripheral BQ25120 (PMIC) which has a default output of 1.8V. I want to increase this voltage to 3.3V for other peripherals. This is possible only by I2C communication.I implemented the interfacing in MQX as well as in bare metal. In MQX, fread returns 0 whereas in bare metal it gives 0xFF.
To see if the code actually works,setup was emulated using K65 evaluation kit and BQ25121 evaluation kit. The code works for 3.3V but not for 1.8V. While probing the SCL,SDA lines using logic analyzer no activity is there. At times, the code actually hits all the breakpoints in 1.8V mode but at times it goes to disassembly.
It would be great if someone can clarify the following doubts and guide me with the same as i am literally stuck with this problem for quite some time.
Hi,
Thanks for the document.But code warrior as well as PEx suite doesn't support k65. So I tried generating code with KDS and PE combined for K65 and changed the values in MQX bsp_cm.c file, but no visible change as of now. Maybe I am not updating at the proper location. Will try again and update you.
But one doubt, Will the clock mismatch issue be responsible for i2c line lock up and hanging? Because after sometime my code is getting stuck in I2C_wait() function in bare metal implementation.
Hi Alex,
You may want to look at the following commuity ticket on which pull resistor value you can use when you are supposed to run at 400kbps for I2C. With 10k pullup, your cap loading on I2C bus will be very small (about 29pF). I suppose for your case, you will not be able to run at 400kbps.
https://community.nxp.com/thread/435467
Hao
Hi Alex,
K65 can work at 1.8V, you can find that TWR K65 board support operating it under 1.8V. For I2C operating under 1.8V, yes, it can. But I would need to have more details from you to know what is happening.
What baud rate you intend I2C operate? Or did you have a chance to measure I2C output and see its baud rate? Which specific I2C pin you used? For K65, some I2C pin are high drive, some are not. What is the I2C pull up you used and how much cap loading you expect on I2C pins?
For the MQX BSP change, I suppose you do have some problem, for you did not have intended clock output on CLKOUT, but this will not impact I2C operation under 1.8V. Which code base you used? Classic MQX or MQX inside KSDK?
Also debugging under 1.8V is possible. What exact problem you have for debugging?
Hao
Hi,
Lack of a stable 1.8V from the regulator was causing my debugging to fail in K65 evaluation kit. I removed all jumpers in J9 and gave 1.8V externally from another power supply at TP14, so the code and everything was working in evaluation Kit.
Regarding clock, what all settings needs to be changed as per external crystal of 24MHz in BSP. I played around with SIM_CLKDIV and VCO divider factors, but no change was happening in the custom board while probing at PTA6. My assumption is clock mismatch is the reason behind all problems in custom board. Please correct me if I am wrong.
I configured I2C0_F factor as 0x16 and the bare metal implementation was working fine on the custom board. The I2C0 lines PTD8 and PTD9 were used with an external pullup of 10k. I want a baud rate of 400Kbps at 60MHz bus clock. It would be great if you can help me in getting in this configuration in MQX.
Hi,
Attached to this, you will find a document that describes how to change default clock settings in Kinetis BSPs.
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------