I am new to Cortex M4 programming I am using teensy 3.2 board .I have connected it to PC using USB to TTL cable.I have written a code to transmit a character from Teensy UART to PC .I am using Dockight as terminal. The baudrate is 9600 for a 72MHZ system clock with 8 data bits ,1 start bit,1 stop bit and no parity bit. I have disabled interrupts and DMA Here is my code
#include "MK20D7.h" void UARTPutChar(char); int main() { SIM->SCGC4=1UL<<10; //Clock Enable Uart0 SIM->SCGC5 =1UL<<12;//Enable GPIO PORT D clock UART0->C2=0X00; //Disable UART Tx PORTD->PCR[7]= 0x00000300; //Port pin declare as UART0TX UART0->BDH=0x01; //9600 baudrate 72MHz system clock UART0->BDL=0xEC; UART0->C1=0X00; UART0->C3=0X00; UART0->S2=0X00; UART0->S1=0X00; UART0->C2=0X08; //Enable UART0 Tx while(1) { UARTPutChar('A'); } } void UARTPutChar(char ch) { //if(UART0->S1 == 0X40) //{ UART0->D=ch; //} }
I have configured Docklight settings correctly but i dont receive the character i transmit Here is what i get
Whereas I should receive Ascii of 'A'.I have my self let the Transmit Empty Flag unused for checking. When i used S1 status flag,nothing is transmitted to PC.
blessed said:I am new to Cortex M4 programming
Do you have experience with programming any other microcontroller(s)? Do you have experience with programming in general?
"Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
Have you used an oscilloscope or analyser to see what the actual baud rate is?
Wrong baud rate is likely due to you not clocking at the speed you thought; check by blinking a LED to see if you get the speed you expected.