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.
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.
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?
Or change the DI divisor?? Perhaps someone with experience with DI can confirm. (ours was done with PE).
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?
Any update.. have you found the solution?
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.
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.
Baud rate is the same - 9600 on putty/Comport ToolKit, and 9600.1454 on k40 (setted in DeviceInit)
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.
FS FAE? What is it?
Freescale Field Application Engineer. Should be able to request assistance from a local office or on line.
Can you get your UART settings? Are you using RTS/CTS, pairity etc?
we use 9600 no parity no rts/cts.
The following calls sets Baudrate with UART_MODULE_CLOCK at 47.75MHz
For 9600 baud
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));
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)