I tried to use c0851F060's UART0,but I found there is no output signal from tx0 and rx0(I using crossbar to mapping tx0 rx0 to P_0,P_1),I don't know why?,so can anyone remind me that any passable wrong I colud make?
C8051F060 UART problem
Aug 10, 2005
4 Replies
I don't know specifically on the F060, but on the F3xx family which we use, the UART pins are permanently assigned to P1.4 and P1.5 and can not be re-assigned via Crossbar. Re-read the manual on use of the crossbar, paying special attention to their examples when I/O pins are skipped. You will notice that the UART function does not shift down in the example.
Pay attention to the SiLabs' specific SFR paging mechanism - do not assume that the usual peripherals are always accessible...
regards
Dejan
This works -
XBR2 |= 0x40; // Enable crossbar and weak pullups XBR0 |= 0x04; //enable UART0
P0MDOUT |= 0xF1; //enable P0 as push-pull outputs //EXCEPT UART0RCV P0.1 and scl,sda .2&.3 P0 |= 0x02; //rx0 open drain explicitly
//----------------------------------------------------------------------------- // UART0_Init RS485 TO PDA //----------------------------------------------------------------------------- // // Configure the UART0 using Timer2, for and 8-N-1. //
void UART0_Init (void) { char old_SFRPAGE = SFRPAGE;
SFRPAGE = UART0_PAGE; // Switch to UART0 page SCON0 = 0x50; // SCON: mode 1, 8-bit UART, enable RX SSTA0 = 0x15; //timer 2 GENERATES BAUDRATE AND DIVIDE BY 2 DISABLED TI0 = 1; // Indicate TX ready
SFRPAGE = old_SFRPAGE; // restore SFRPAGE }
void Timer2_Init() //UART0 BAUD RATE GENERATOR { char old_SFRPAGE = SFRPAGE;
SFRPAGE = TMR2_PAGE; // Switch to Timer 2 page
TMR2CF = 0X08; //SYSCLK
RCAP2H = 0XFF; #ifdef ninetysix RCAP2L = 0X70; //9600 BAUD WITH 22.1184 MHZ SYSCLK #endif #ifdef nineteentwo RCAP2L = 0XB8; //19200 BAUD WITH 22.1184 MHZ SYSCLK #endif #ifdef thirtyeightfour RCAP2L = 0XDC; //38400 BAUD WITH 22.1184 MHZ SYSCLK #endif #ifdef onefifteentwo RCAP2L = 0XF4; //115200 BAUD WITH 22.1184 MHZ SYSCLK #endif
TMR2CN = 0X04; // ENABLE TIMER2 SFRPAGE = old_SFRPAGE; // restore SFRPAGE
}By the way, Who was the comic who named the register bit for enabling weak pullup devices "WEAKPUD" ?
Bob
thanks Bob! sorry,I am busy recently,so take so long to reply your message. I still can't let UART0 working ....I use RS-232 check tester the Tx led didn't light,so I past the program,hope someone can help me. please~~ orz
#include // SFR declarations
int i; char g=0x35;
void Oscillator_Init() { SFRPAGE = CONFIG_PAGE; OSCICN = 0x82; }
void Timer_Init() { SFRPAGE = TMR2_PAGE; TMR2CN = 0x04; RCAP2L = 0xFD; RCAP2H = 0xFF; }
void UART_Init() { SFRPAGE = UART0_PAGE; SCON0 = 0x50; SSTA0 = 0x05; }
void Port_IO_Init() { // P0.0 - TX0 (UART0), Push-Pull, Digital // P0.1 - RX0 (UART0), Open-Drain, Digital // P0.2 - Unassigned, Open-Drain, Digital // P0.3 - Unassigned, Open-Drain, Digital // P0.4 - Unassigned, Push-Pull, Digital // P0.5 - Unassigned, Push-Pull, Digital // P0.6 - Unassigned, Push-Pull, Digital // P0.7 - Unassigned, Push-Pull, Digital
// P1.0 - Unassigned, Open-Drain, Digital // P1.1 - Unassigned, Open-Drain, Digital // P1.2 - Unassigned, Open-Drain, Digital // P1.3 - Unassigned, Open-Drain, Digital // P1.4 - Unassigned, Open-Drain, Digital // P1.5 - Unassigned, Open-Drain, Digital // P1.6 - Unassigned, Open-Drain, Digital // P1.7 - Unassigned, Open-Drain, Digital
// P2.0 - Unassigned, Open-Drain, Digital // P2.1 - Unassigned, Open-Drain, Digital // P2.2 - Unassigned, Open-Drain, Digital // P2.3 - Unassigned, Open-Drain, Digital // P2.4 - Unassigned, Open-Drain, Digital // P2.5 - Unassigned, Open-Drain, Digital // P2.6 - Unassigned, Open-Drain, Digital // P2.7 - Unassigned, Open-Drain, Digital
// P3.0 - Unassigned, Open-Drain, Digital // P3.1 - Unassigned, Open-Drain, Digital // P3.2 - Unassigned, Open-Drain, Digital // P3.3 - Unassigned, Open-Drain, Digital // P3.4 - Unassigned, Open-Drain, Digital // P3.5 - Unassigned, Open-Drain, Digital // P3.6 - Unassigned, Open-Drain, Digital // P3.7 - Unassigned, Open-Drain, Digital
SFRPAGE = CONFIG_PAGE; P0MDOUT = 0xF1; XBR0 = 0x04; XBR2 = 0x40; }
// Initialization function for device, // Call Init_Device() from your main program void Init_Device(void) { Oscillator_Init(); Timer_Init(); UART_Init(); Port_IO_Init(); }
void delay(int x) { int i; for(i=0;i
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required