Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/11/04 06:28
Read: times


 
#82931 - C8051f320 UART problem
I am using the C8051f320 chip from silicon laboratories. For my application I have to send some adc data through serial port. The program works for baudrates 38400 and higher. However I don't receive the data correctly on hyperterminal for lower values(e.g. 9600 or 19200). Can somebody help me solve the problem. In debug mode I can see the data is written correctly.
Calculation of baudrate manually also indicates that put value for timer1 is correct. I am using keil compiler.
My uart initialisation function is as follows (SYSCLK value is 120000000):-
//-----------------------------------------------------------------------------
// UART0_Init
//-----------------------------------------------------------------------------
//
// Configure the UART0 using Timer1, for <BAUDRATE> and 8-N-1.
//
void UART0_Init (void)
{
SCON0 = 0x10; // SCON0: 8-bit variable bit rate
// level of STOP bit is ignored
// RX enabled
// ninth bits are zeros
// clear RI0 and TI0 bits
if (SYSCLK/BAUDRATE/2/256 < 1) {
TH1 = -(SYSCLK/BAUDRATE/2);
CKCON &= ~0x0B; // T1M = 1; SCA1:0 = xx
CKCON |= 0x08;
} else if (SYSCLK/BAUDRATE/2/256 < 4) {
TH1 = -(SYSCLK/BAUDRATE/2/4);
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 01
CKCON |= 0x09;
} else if (SYSCLK/BAUDRATE/2/256 < 12) {
TH1 = -(SYSCLK/BAUDRATE/2/12);
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 00
} else {
TH1 = -(SYSCLK/BAUDRATE/2/48);
CKCON &= ~0x0B; // T1M = 0; SCA1:0 = 10
CKCON |= 0x02;
}

TL1 = TH1; // init Timer1
TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit autoreload
TMOD |= 0x20;
TR1 = 1; // START Timer1
TI0 = 1; // Indicate TX0 ready
}

List of 6 messages in thread
TopicAuthorDate
C8051f320 UART problem            01/01/70 00:00      
   Additional information            01/01/70 00:00      
      The onboard oscillator.            01/01/70 00:00      
         Thankyou. Its working            01/01/70 00:00      
   It's CKCON setting error            01/01/70 00:00      
   How to post code            01/01/70 00:00      

Back to Subject List