I am using TWR-SER with MCF52259..The default baud rate i am using for serial communication is 115200..But when i tried 19200 or above 115200 its not working...i changed the baudrate setting macro #define BSPCFG_UART1_BAUD_RATE in m52259evb.h of the project /Freescale MQX 3.7/mqx/build/cwcf72/bsp_m52259evb/...its still not working...please let me know if i am doing it the right way.
Working with the "M52259EVB Big Board" the CONFIGURE_UART0 subroutine is called on power up to set up the default
baud rate of 19.2Kbaud.
The SET_BAUDRATE_COMMAND_HANDLER subroutine is called when a command is sent from a PC to change the baude rate.
I'm using the PLL to run the clock at 80 MegaHz.
This same code ran fine on the "M52259DEMO little board" also, (until I blew it up).
Hopefully this exerpt will help with your problem:
////////////////////////////////////////////////////////////////////////////////////////////////////
// Configure the on board serial channel for PC communications.
// For the V2 this is UART0.
// This is called from powerup.
////////////////////////////////////////////////////////////////////////////////////////////////////
//BAUD_RATE = 260 //{80000000/32/9600} // 9600 baud with an 80 Mega Hz clock
BAUD_RATE = 130 //(80000000/(19200 * 32)) //19.2K baud with an 80 Mega Hz clock
//BAUD_RATE = 65 //(80000000/(38400 *32)) //38.4K baud with an 80 Mega Hz clock
.align 2
CONFIGURE_UART0:
//PUAPAR - pin usage
MOVE.B (PUAPAR).L,%D0 //or bits into the io configuration to select the primary functions
ORI.L #0x05,%D0 //set rxeive and tranxmit pins for use by uart 0, BUT not RTS
MOVE.B %D0,(PUAPAR).L //Don't disturb the other bits in PUAPAR
//UCR0 - Command the Uart to reset its Transmitter
MOVE.B #0x30,%D0
MOVE.B %D0,(UCR0).L
//UCR0 - Command the Uart to reset its Receiver
MOVE.B #0x20,%D0
MOVE.B %D0,(UCR0).L
//UCR0 - Command the uart to reset its pointer to the Mode Register
MOVE.B #0x10,%D0
MOVE.B %D0,(UCR0).L
//UMR10 - No parity, 8-bits per character
MOVE.B #0x13,%D0
MOVE.B %D0,(UMR10).L
//UMR20 - No echo or loopback, 1 stop bit
MOVE.B #0x7,%D0
MOVE.B %D0,(UMR20).L
//UCSR0 - Uart Clock Select, Rx and Tx baud based on SYSTEM CLOCK
MOVE.B #0xDD,%D0
MOVE.B %D0,(UCSR0).L
//UIMR0 - Uart Interrupt Mask Register, Mask all UART interrupts
CLR.L %D0
MOVE.B %D0,(UIMR0).L
//UBG10 - and UBG20 are not contiguous addresses, but they represent a 16 bit number.
//The baudrate clock divisor. UBG10 is the MSByte and UBG20 is the LSByte.
MOVE.L #BAUD_RATE,%D0
MOVE.B %D0,(UBG20).L //set LSByte
ASR.L #8,%D0 //Shift MSByte into position.
MOVE.B %D0,(UBG10).L //Set MSByte of divisor.
//HERE UNMASK THE VECTORS AND THE icrS FOR TRANSMIT AND RECEIVE
//IMRL0 - Enable Interrupts for UART0 source 13 on INTC0, this is vector 77 overall (64+13)
//Zero the interrupt MASK bit for UART0 and the "mask All" bit.
MOVE.L (IMRL0).L,%D0
ANDI.L #0xFFFFDFFE,%D0 //0x2001 inverted
MOVE.L %D0,(IMRL0).L //clear the mask bit and the mask all bit
//ICR013 set the interrupt "level" and "Priority" for PIT0's interrupt
//THe UART will run faster than the timer but slower than CAN and USB so the
//level and priority chould be higher than PIT0 but lower than those other two.
MOVE.B #0x24,%D0 //Level 4, Priority 5 (example PIT main used 4, 4)
MOVE.B %D0,(ICR013).L
//UCR0 - Command the uart to Enable its receiver and transmitter
MOVE.B #0x5,%D0
MOVE.B %D0,(UCR0).L
CLR.L (PC_SEND_BUF_PTR).L //Zero the send buffer pointer
MOVE.B #0,%D0 //Send a NULL character right after powerup to eliminate
BSR SEND_CHAR_NOW //a garbage character at the beginning of the first message.
MOVE.B #0,%D0 //Send a NULL character right after powerup to eliminate
BSR SEND_CHAR_NOW //a garbage character at the beginning of the first message.
RTS
////////////////////////////////////////////////////////////////////////////////////////////////////
//BAUD_RATE = 520 //(80000000/(4800 *32)) //38.4K baud with an 80 Mega Hz clock
//BAUD_RATE = 260 //{80000000/32/9600} // 9600 baud with an 80 Mega Hz clock
BAUD_RATE = 130 //(80000000/(19200 * 32)) //19.2K baud with an 80 Mega Hz clock
//BAUD_RATE = 65 //(80000000/(38400 *32)) //38.4K baud with an 80 Mega Hz clock
//BAUD_RATE = 43 //(80000000/(57600 *32)) //38.4K baud with an 80 Mega Hz clock
//BAUD_RATE = 22 //(80000000/(115200 *32)) //38.4K baud with an 80 Mega Hz clock
////////////////////////////////////////////////////////////////////////////////////////////////////
.align 2
SET_BAUDRATE_COMMAND_HANDLER:
CLR.L %D0
MOVE.B (%A0)+,%D0
CMP.L #SPACE,%D0 //there must be one space.
BEQ.B CONVERT_NEW_BAUDRATE
JMP (FORMAT_ERROR).L
CONVERT_NEW_BAUDRATE:
CLR.L %D1
JSR (DECIMAL_TO_BINARY).L
TST.L %D1
BEQ.B CONVERTED_OK
JMP (FORMAT_ERROR).L
CONVERTED_OK:
CMP.L #4800,%D0 //12C0
BEQ.B BAUD_OK
CMP.L #9600,%D0 //2580
BEQ.B BAUD_OK
CMP.L #19200,%D0 //4B00
BEQ.B BAUD_OK
CMP.L #38400,%D0 //9600
BEQ.B BAUD_OK
CMP.L #57600,%D0 //E100
BEQ.B BAUD_OK
CMP.L #115200,%D0 //1C200
BEQ.B BAUD_OK
JMP (FORMAT_ERROR).L
BAUD_OK:
//Calculate the number for the Silicon 80000000/32/baudrate
MOVE.L %D0,%D1
MOVE.L #2500000,%D0 //8000000/32 = 2500000
JSR (DIVIDE).L //divided by the baud rate
//UBG10 - and UBG20 are not contiguous addresses, but they represent a 16 bit number.
//The baudrate clock divisor. UBG10 is the MSByte and UBG20 is the LSByte.
MOVE.B %D2,(UBG20).L //set LSByte
ASR.L #8,%D2 //Shift MSByte into position.
MOVE.B %D2,(UBG10).L //Set MSByte of divisor.
LEA.L (NEW_BAUD_MSG).L,%A0
JSR (DISPLAY_MESSAGE).L
RTS
NEW_BAUD_MSG: .asciz "baudrate changed\r"
I forgot, I've never attempted to push it faster than 115200. (115200 seems to work fine, but I've never been able to type fast enough to require more). If you get it going faster let me know.