Impleting USART on XC888-CM-8FFA with XC800LQFP easy kit

Status
Not open for further replies.

ddr123ab

Newbie level 2
Joined
May 4, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
xc888

I was trying to send something to the hyperterminal using the USART. Below is the of the sample code i try. This is the setting of the the hyperterminal: 9600bps baud rate, 0 stop bit, parity bit none and flow control none. But nothing come out in the hyperterminal. Please Help.

Please add me msn at ddp213@hotmail.com if u can help. Thanks.

#include "MAIN.H"

void MAIN_vInit(void)
{
SFR_PAGE(_su1, noSST);
CMCON = 0x10;
SFR_PAGE(_su0, noSST);
IO_vInit();
UART_vInit();
IP = 0x00;
IPH = 0x00;
IP1 = 0x00;
IPH1 = 0x00;
EA = 1;
}


void main(void)
{
MAIN_vInit();
TI = 1;
while(1)
{
}
}

void IO_vInit(void)
{
P3_DIR = 0xC0;
}

void UART_vInit(void)
{
SFR_PAGE(_pp2, noSST); // switch to page 2 without saving
P1_ALTSEL0 &= ~(ubyte)0x02; // configure alternate function

register 0
P1_ALTSEL1 |= (ubyte)0x02; // configure alternate function

register 1
SFR_PAGE(_pp0, noSST); // switch to page 0 without saving
P1_DIR |= (ubyte)0x02; // set output direction


MODPISEL &= ~(ubyte)0x01; // configure peripheral input select

register
BCON = 0x00; // reset baudrate timer/reload

register
SCON = 0x50;
BG = 0x9B; // load baudrate timer/reload register
BCON |= 0x01; // load baud rate control register
ES = 1;
}

void UART_viIsr(void) interrupt UARTINT
{
SFR_PAGE(_su0, SST0);
if (TI)
{
TI = 0;
}
if (RI)
}
RI = 0;
P3_DATA ^= 0x40; // toggle P3.6 on EK-888 after receive byte
printf ("Hello World\n"); /* Print "Hello World" */
}
SFR_PAGE(_su0, RST0);
}
 

Hi, I am Giuliano from Rome, Italy
I am developping a XC888 board with a Assembler programming and I try to help you if you are still interesting ...

1) Are you using either internal or external oscillator ? Because if you connect an external xtal, the BRG register must be programmed with a different value depending on that frequency

2) When your program is running can you monitor with a scope if a serial signal is generate ?

3) If yes at point 2) check if the relevant period is correct (i.e. @9600bit/s any bit period is about 100µs long) or either major / minor of this value and correct the BRG register value

If you need more help try to write to ggalt@libero.it

By

Giuliano
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…