IIC Clock use and Uart start/stop bit on Coldfire

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IIC Clock use and Uart start/stop bit on Coldfire

2,305 Views
adrien_segura12
Contributor I

Hi,

I work on Codewarrior 10.4 with a PE multilink universal on a coldfire MCF51CN128.

My objective is to imitate an IIC and an UART frame, and on both, i have problems :

-On my IIC frame, i succeed to imitate the initial frame with the SDA (data), but, the SCL (clock) is not exactly the same :

my generated frame :

pastedImage_1.png

and the frame i want :

pastedImage_2.png

I apologize for the poor quality of my records. Green : SCL, Yellow : SDA.

The objective of the IIC is a transmission only : the Coldfire MCF51CN128 transmit this data to a TCA6424A without any return. as you can see, there is a problem between frames : the "end of trame" is not here on my generation, and more important, my end of transmission isn't good. It has to be like this :

pastedImage_3.png

and, on my generated frame,the stop condition is wrong.

-On my UART frame i succeed to generate a frame with exactly the good data that i need, but, what i try to imitate isn't a single frame, it's 2 frames who take turns. The problem is : My communication start is too long : it is 3 bits longs to high level before the communication starts, given that there is 2 frames , i have 3 bits instead of 1 on the middle of my communication. This UART communicates with a kinetis MKL03Z16.

Any ideas of what are my problems? Thanks for the help and for your attention ! Have a nice day !

Adrien Segura

Labels (1)
0 Kudos
13 Replies

2,101 Views
adrien_segura12
Contributor I

Hi everyone !

The problem has been resolved, it was a mistake from me on the date i used was not correct.

Also, the various time at the start of the UART is not a problem on an RS485 protocol.

Still don't understand why my IIC module doesn't work, but i'll try to fix it.

Thanks a lot for your help !

Adrien Segura

0 Kudos

2,101 Views
TomE
Specialist II

> I am enabling the MAX3072E in initialisation, and then my UART code looks like this

So either your initialisation code is taking a variable amount of time for some reason, or the UART is taking a variable amount of time before it will allow that first transmission. Turn the LED on when you enter the UART transmit routine to see which one it is.

Why does this variability matter? If you're using a RS-485 bus then the protocol specifies the enable and turnaround time, and your code had better be written to get that right in all cases. Unless you only have to send one message after powerup to "copy" the existing product. Which should be unlikely.

Tom

0 Kudos

2,101 Views
TomE
Specialist II

I am confused about what you are doing. I think Hui is as well.

When you said "imitate a frame" we think you're meaning that you are writing code loops to try and emulate I2C and/or UART in software loops. This is strange as the MCF51CD128 has two I2C modules and three UART modules.

So are you using those hardware modules, or are you using "loops in code" to try and generate waveforms? If you're doing "loops in code", then WHY?

Clear that up and then I might have some suggestions.

Tom

0 Kudos

2,102 Views
adrien_segura12
Contributor I

Hi,

Sorry for beeing inprecise.

I have 2 IIC modules and 1 UART module.

I have two exactly identical cards with the ship MCF51CN128, one has a program loaded inside wich is functionnal, the other is the one i try to program.

The objective of the card i'm programming is to be exactly the same as the first one, but with some minor modifications i already made.

but then why don't i use the fonctionnal program ? because i don't have it, i just have a functionnal card without his code.

So, on the card i'm programming, the frames i tried to imitate are just slightly different from the original, and are not problems of data.

Thanks for your attention and for your help !

Adrien Segura

0 Kudos

2,102 Views
TomE
Specialist II

Hui Ma has given a confusing response as he has used the words 'GPIO emulation code". I have no idea how you can emulate GPIO, or maybe he meant using timed code and the GPIOs to emulate a UART. We now know that's not what you're doing.

However, you're not using the UART to just transmit and receive data as the oscilloscope trace is showing three levels. So you must be using a serial protocol that has multiple devices sharing a single wire, like LIN. But according to your oscilloscope trace, using +-3V or so.

So you must be using a GPIO pin to enable the transceiver (and a different one to turn the LED on) and then write to the UART to send data.

You're getting a variable time between those two writes to the GPIO and when the UART start transmitting. That can only mean one of two things. Either your code is taking a variable time between those two operations, or the UART is taking a variable time to start. How are you enabling the transmitter, and when in your oscilloscope sequence? Are you programming it to "send idles"? It might be sending "frames of idles" and can only start sending the character you want to transmit when the previous send or idle has finished.

As for the I2C problems, it looks like you're not generating the STOP condition. Look at the flow charts. You have to set MST=0 to generate a stop condition.

Tom

0 Kudos

2,102 Views
adrien_segura12
Contributor I

Hi,

Thanks for your answers, And yes, i am using a double wire RS485,And again yes, i am using a GPIO pin to enable a MAX3072E , and then, i use the UART to transmit data.

I am enabling the MAX3072E in initialisation, and then my UART code looks like this :

EnTx = 1 ; // enable of MAX3072E in initialisation

SCI1C2_TE = 1 ; // enable Transmit UART 

while( (SCI1S1 & SCI1S1_TDRE_MASK )== 0 ){}

SCI1D = firsframe ;

while ((SCI1S1_TC & SCI1S1_TDRE) != 1 ); 

SCI1C2_TE = 0 ; // end of transmit

For my IIC, i got wrong cause of my oscilloscope, my stop condition is well generated at the end i correctly used MST=0 in my IIC program.

0 Kudos

2,102 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Thank you Tom.

Adrien didn't use GPIO pins to emulate a UART/I2C communication, instead he used MCF51CN128 I2C/SCI modules to do that communication. That make sense. When I replied Adrien's question, I still thought he was using GPIO pins do UART/I2C communication emulation works, in fact, I was totally wrong. Thanks.

best regards,

Mike

0 Kudos

2,102 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

From the description, customer doesn't use MCF51CN128 chip provided I2C/SCI module, using GPIO pins emulate I2C/UART instead.

About I2C port, please make sure there with 4.7Kohm pull up resistors with both emulated I2C_SDA, I2C_SCL pins.

If possible, slow down the I2C bus baud rate, if that working with the external I2C device.

Wish it helps.


Have a great day,
Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,102 Views
adrien_segura12
Contributor I

Hi,

Thanks for your answer .

both of my IIC modules comunicates with a ship specialized for IIC : TCA6424A and PCA9535 and i send them the necessary data to put them in write mode, with their correct default adress (also i didn't fully understand if the adress register for the master is useful if he only transmit data).

Both of my IIC modules have their pull up resistors :

pastedImage_1.png

I also tried the communication with a lower Baudrate, unfortunately, it doesn't change anything.

I don't know if we have to initialize the ships TCA6424A and PCA9535 with some kind of intialization frame.

I didn't find anything of this kind on their datasheet ,but, i'm new on IIC.

For my UART communication, i will try what you said.

Thanks for your feedback !

Anyone has any ideas? Thanks again !

Adrien Segura

0 Kudos

2,102 Views
adrien_segura12
Contributor I

Hello everyone,

I just add some things concerning the UART module :

The problem is kinda strange , the program just loop on himself, and, half of the time, the frame send is not the same :

pastedImage_1.png

or

pastedImage_2.png

in yellow the Data send on UART,

in green (state of a led ), the status of transmission : high : transmission active , low : transmission finished.

as you can see, the first frame to transmit is sometimes way too long, but, the second one is always short.

the data send is  0x40 for the first frame, and 0xDB for the second frame.

Also the begginning of both transmissions is too long : i should have just one start bit for each frame. Those frame does

not work.

Any ideas of how to reduce the lenght of the beginning ? or what is the reason of this behavior?

Thanks a lot for your help !

Adrien Segura

0 Kudos

2,102 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I suspected the GPIO emulation code was halted/interrupted by another higher level application or interrupt service routine at the first frame to transmit.

It need to disable all interrupt resource to make sure GPIO emulation code with highest priority to occupied the code(run the code).

pastedImage_1.png


Have a great day,
Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,102 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Adrien,

Could you remove those 100pF capacitors with I2C lines?


Have a great day,
Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,102 Views
adrien_segura12
Contributor I

Hi,

Thanks for the answer but no, i can't take those capacitor back.

But the fact is that they do not disturb the good work of the IIC module.

The frame i try to imitate is from the exact same card so it should work with the capacitors.

Thanks for your help !

Any other ideas?

Adrien Segura

0 Kudos