Hello,
I use the I2C bus of the MKL17Z256VFT4 at 400KHz. When I have the PE Multilink universal connected to the board it works perfectly, when I unplug the Mulitlink it always works but when I restart my board the I2C bus doesn't work. I know my program is running because I do a blink of a LED thanks to a PIT_Interrupt. I have 2 I2C slaves on the bus and no response of the both so I think it's from the MCU.
On BK000001.BMP it's I2C frame when it works and on BL00002.BMP when it doesn't work. This last appears just one time at the start-up of the MCU, after this the bus remains in Vcc State. I think the MCU try a first communication then abandons.
It seems the clock doesn't want to works, SDA fall to "0" but not the SCL.
Sam,
Solved! Go to Solution.
Hi Samuel,
Thank for your good question, and sorry for the inconvenience we bring you!
After debugging with JLINK tool, we have found the factor which have caused the LPUART can't receive the data, because the code enter FlexIO interrupt handler.
So, now please disable the flexIO interrupt in your main code:
NVIC_DisableIRQ(30);
Please do it like this:
After the modification, then download the code to your KL17 chip, and try it again, you will receive the data with LPUART.
Any question you meet, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Samuel,
Thank for your good question, and sorry for the inconvenience we bring you!
After debugging with JLINK tool, we have found the factor which have caused the LPUART can't receive the data, because the code enter FlexIO interrupt handler.
So, now please disable the flexIO interrupt in your main code:
NVIC_DisableIRQ(30);
Please do it like this:
After the modification, then download the code to your KL17 chip, and try it again, you will receive the data with LPUART.
Any question you meet, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jingjing,
After the first tests it seems to be work again! my LPUART AND I2C problem is resolved and this with the call of bootloader during my application too! I'm a relief.
So just one questions:
Is PE should have initiliaze this (and this is a problem with PE) or I should have make this myself ?
Hi Samuel,
PE won't do it, so customer need to disable it by himself now.
But I will transfer this problem to our according department, to check whether they can add it.
Any way, thank you for your good question!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you for your help, happy to help to improve this, even if I would have prefered to avoid this debug.
So I'm surprised to see I'm the first to have this problem with the MCU. No chance for me...
Hi Smauel,
Do you have any other questions?
If you don't have it, could you please click the Correct Answer button. Thank you!
Jingjing
Hi Samuel,
Could you tell me what the clock source you are using? Internal clock or external crystal?
You said:PE Multilink universal connected to the board it works perfectly, when I unplug the Mulitlink it always works but when I restart my board the I2C bus doesn't work.
Do you mean, just connect the debugger, and don't enter in the debug mode? Or when do debugging the code works ok?
Besides, did you add the external pullup resistor in the I2C_CLK and I2C_DAT pin?
You can send me your project, I would like to help you to check it on my side.
Waiting for your reply.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
- It's an external 12Mhz Crystal.
- It's when I debug the code, it works well. During this debug I unplug the Multilink and it always works.However when I restart my board (electrical reset) it doesn't work (with or without the multilink connected to the board). I did the test without debug mode but just flashing the MCU with KDS too and same result, just after flashing it's OK, when I unplug the probe always OK but after restart : KO.
External pull-up are soldered, it was 8k2 resistors, but rise time was so long and I placed two 1K in parallel for the 2 lines, so equivalent pull-up are 500 ohms for my tests (communication at 400kbits/s).
Can you give me an adress mail to send the project please ?
I hope to resolve this problem rapidly because with this problem 2 important functionnalities of my design are KO, it's bad I need it ASAP.
Thank you,
Sam
Hi Samuel,
You can attached your project directly.
If it is confidential to you, you can delete all the other important code, just leave the I2C initialize and communication code.
I will test it on my side.
Now please test these points on your side:
1. bus clock frequent checking
Please configure PTC3 as the CLKOUT, and output the bus clock, test it in debug and none debug mode independently.
Whether the bus frequency is changed.
2. Add some delay after power on in the main function, and before the I2C configuration.
For example, add 1 second delay, then test it again.
3. electrical reset, do you mean POR?
Try use the pin reset in PTA4, don't use POR reset again.
Waiting for your reply!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
1) I don't find how to configure PTC as CLKOUT with PE...otherwise I have a UART Tx chip connected on this pin pulling up the signal to Vcc, it seems not possible to send the CLK here...no ?
2) Delay have no effect...
3) Yest it's a POR. The regulator who supplies the MCU is "Enable or Disabled" by a battery powered hardware.
I tried to pull down PTA4 with no effect. I saw in the datasheet this pin is disabled when boot from ROM, it's my case.
I can't post the complete project so I join a cleaned project. I tested it and he have a different behaviour, it seems that the MCU try to launch an I2C communication permanently without success, the CLK toggles chaotically. I can send the complete project only to a private mail.
Hi samuel,
CLKOUT configuration, please add this code.
SIM_SCGC5|=SIM_SCGC5_PORTC_MASK;
PORTC_PCT3 = PORT_PCR_MUX(5) | PORT_PCR_PE_MASK_PORT_PCR_PS_MASK;
SIM_SOPT2 = SIM_SOPT2_CLKOUTSEL(2) ;
Then test the PTC3 pin on your board.
About other questions, I will reply you after I check your sample code, please wait patiently.
Thanks a lot for your understanding.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Isn't there an error on the second line of the code ? :
- PORTC_PCT3 --> PORTC_PCR3
- PORT_PCR_PE_MASK_PORT_PCR_PS_MASK --> isn'' it a mix of 2 define ? eilther PORT_PCR_PE_MASK or PORT_PCR_PS_MASK ?
I think there will be a conflict with the Tx pin of another chip wonnected at this port but I will try.
EDIT :
I tested with PORTC_PCR3 = PORT_PCR_PE_MASK and I have a Clock at 24 Mhz.
Hi Samuel,
Yes, you are correct, I typed the wrong word, I want to write PORTC_PCR3, it is the type error, it should be:
SIM_SCGC5|=SIM_SCGC5_PORTC_MASK;
PORTC_PCR3 = PORT_PCR_MUX(5) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK;
SIM_SOPT2 = SIM_SOPT2_CLKOUTSEL(2) ;
But now, you already get the bus clock.
Jingjing
Hi,
Correction already done, Clock works well. You can find my observation about the bootloader below.