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.
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?
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.
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.
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)