k40 problem with UART

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

k40 problem with UART

4,141 Views
GerasinIvan
Contributor II

Hi,

I have a problem with UART - I'm trying to send data to computer, but get only garbrage. I tried to on/off parity with 8/9 bits, but it doesn't help. Data cable is ok (i tried 2 cables). Send data with TWR-SER.

send with^

while(!(UART3_S1) & UART_S1_TDRE_MASK));

UART_D = 0xFF;

and i get date like 7F

or sometimes different data BF FF FD

What's the problem?

Thx for help.

Labels (1)
Tags (4)
0 Kudos
Reply
14 Replies

3,079 Views
GerasinIvan
Contributor II

So, as i previously said - it's problem with DevInit. For 9600 on receiver, i set Baud Rate Divisor 165. And DI calculate baud rate - 7897. May be i should change processor freq in settings of DI?

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

Or change the DI divisor?? Perhaps someone with experience with DI can confirm. (ours was done with PE).

0 Kudos
Reply

3,079 Views
GerasinIvan
Contributor II

Well, i looked at "System Clock" in Component Inspector, and saw that "Core clock" - 29.97Mhz and the "Bus clock" is the same. What is it? As I know, Core should be 50MHz (or above), and bus in half of that value. And i free to change it. I think it's not right.

And another question: can i directly connect rs232 connector to UART pins or must i use any micro's to convert signal?

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

Any update.. have you found the solution?

0 Kudos
Reply

3,079 Views
GerasinIvan
Contributor II

I haven't free time to work at this problem, but i suggest that there it's problem with Device Initializator. Than i used a PWM on FlexTimer, it shows that period is 20.00 ms, but really it wasn't. To make 20ms period, i configured DI, that it shows about 23.~~ ms. I saw it with oscilloscope. So, in next week i will try UART once more.

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

Experiment with the clock if you cannot find the settings.


Check the KQRUG doc and other guides, and the K40 Resource manual: http://bit.ly/WxlIak

For the connection: The UART pins are 3.3v signals, RS232 are higher and swing + and -.

Look at the Tower Serial  schematics.  The RS232 9-pin connector is connected through a level shifter IC U6.

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

Baud rate.??

0 Kudos
Reply

3,079 Views
GerasinIvan
Contributor II

Baud rate is the same - 9600 on putty/Comport ToolKit, and 9600.1454 on k40 (setted in DeviceInit)

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

We used PE to set up our RS232 on UART2 with no issues...  Even have the options to change Baud-rate on the fly.

I have seen in other post that UART3 on some KXX's uses a different clock source , no firsthand knowledge of that if it is your issue.

Look for updates to Device Init.

Try any examples for TWR-SER you can find.. and Call a FS FAE directly for assistance.

But you may already be have gone thru all this.

0 Kudos
Reply

3,079 Views
GerasinIvan
Contributor II

FS FAE? What is it?

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

Freescale Field Application Engineer. Should be able to request assistance from a local office or on line.

0 Kudos
Reply

3,079 Views
GerasinIvan
Contributor II

Can you get your UART settings? Are you using RTS/CTS, pairity etc?

0 Kudos
Reply

3,079 Views
Jack_at_Oxigraf
Contributor III

we use 9600 no parity no rts/cts.

The following calls sets Baudrate with UART_MODULE_CLOCK at 47.75MHz

UART_PDD_SetBaudRateFineAdjust(UART2_BASE_PTR, baudFineAdj[newBaud]);

UART_PDD_SetBaudRate(UART2_BASE_PTR, baudDivisor[newBaud]);

For 9600 baud

baudDivisor =310

baudFineAdjust=28

0 Kudos
Reply

3,079 Views
lothar
Contributor II

Hi

I use UART on the K20 tower board but it should be about the same for the K40.

UART0 and UART1 use the core clock the other UART channels are using the bus clock. In my case the core clock is twice as fast as the bus clock.

The UART init function within the drivers (uart.c) is only turning on the clock, enables tx/rx and sets the clock divider bits srb and brfa. The only thing left to do is giving the Pins the right function (e.g. PORT_PCR_MUX(0x3)).

/* Calculate baud settings */

sbr = (uint16)((sysclk*1000)/(baud * 16));

/* Determine if a fractional divider is needed to get closer to the baud rate */
brfa = (((sysclk*32000)/(baud * 16)) - (sbr * 32));

Maybe you are doing the sbr calculation wrong. brfa is not important when setting slow baudrates and its wrong anyway (overflow occures, what caused me some troubles by setting baudrate to 921'600).

If you do these settings you should see 10 bits with the KO (start,data,stop --> the lsb comes first)

0 Kudos
Reply