AnsweredAssumed Answered

I need help with UART5 on TWR-K60N512

Question asked by Ricardo Moreira on Feb 22, 2015
Latest reply on Feb 23, 2015 by Butcher

I'm having problems working with UART5 to communicate with the pc through USB. I'm trying to send a message to the pc, therefore i'm only using Tx. The problem is that i'm trying to write in some registers but the values don't change. Also, i don't know how to set the baud rate to 9600 bps.
I would appreciate some help. The program is what follows:

 

 

#include "derivative.h" /* include peripheral declarations */

 

int main(void)

{

  int i;

  uint8_t message[] = "Hello World";

 

  //enable clock to port E

  SIM_SCGC5 |= 1<<13;

 

  //enable clock to UART5 module

  SIM_SCGC1 |= 1<<11;

 

  //set pin 8 from port E as UART5_Tx

  PORTE_PCR8 |= 0x00000300;

 

  //Disable Receiver and Transmitter to change UART settings

  UART5_C2 &= ~0x0c;

 

  // Configure the UART for 8-bit mode, no parity

  UART5_C1 = 0;

 

  //Set the baud rate          - > I don't know how to set the baud rate to 9600 bps

  UART5_BDL = 4; //UART_BDL_SBR(9600);

  UART5_BDH = 4;

 

  //Enable Transmitter

  UART5_C2 |= 1<<3;

 

  //Writing in the transmitter data register

  for (i = 0; message[i] != '\0'; i++) {

  UART5_D = message[i];                 - > the register doesn't change and i don't know why

  }

 

  return 0;

}

 

Thanks!

Outcomes