Raady Here
Full Member level 5
- Joined
- Jun 8, 2013
- Messages
- 242
- Helped
- 26
- Reputation
- 52
- Reaction score
- 26
- Trophy points
- 28
- Location
- India
- Activity points
- 1,571
PIC18F4520
MPLAB 8.8
Hi,
I have configured for UART, and used 8Mhz internal osc
OSCCON = 0x72;
so corresponding SPBRG = 51, and uart is working fine.
but while I was enabling PLL with INTOSC by
OSCTUNEbits.PLLEN = 1; // PLL enabled
it doesnt show any effect
I have changed SPBRG = 207 after the calculations given in datasheet. UART does print some garbage values.
but if i give SPBRG = 51 it works fine.
How to enable PLL for int osc ?
baud rate chosen 9600
Configuration used
MPLAB 8.8
Hi,
I have configured for UART, and used 8Mhz internal osc
OSCCON = 0x72;
so corresponding SPBRG = 51, and uart is working fine.
but while I was enabling PLL with INTOSC by
OSCTUNEbits.PLLEN = 1; // PLL enabled
it doesnt show any effect
I have changed SPBRG = 207 after the calculations given in datasheet. UART does print some garbage values.
but if i give SPBRG = 51 it works fine.
How to enable PLL for int osc ?
baud rate chosen 9600
Configuration used
Code:
void init_uart(void)
{
TRISCbits.TRISC6 = 0; // Tx - UART pin # 25
TRISCbits.TRISC7 = 1; // Rx - UART pin # 26
//SPBRGH // disabled in 8 bit mode of BRG
SPBRG = 51; // 9600 baud rate 8 MHZ int osc
RCSTAbits.SPEN = 1; // Serial port enabled
RCSTAbits.CREN = 0; // 0 - Disable recevier
TXSTAbits.TX9 = 0; // 8 bit mode tranmission
TXSTAbits.SYNC = 0; // Asyn mode
TXSTAbits.BRGH = 1; // High Speed
TXSTAbits.SENDB = 0;
TXSTAbits.TX9D = 0;
TXSTAbits.TXEN = 1; // Transmit enabled
BAUDCONbits.ABDOVF = 0; // No BRG rollover occured
BAUDCONbits.RCIDL = 1; // recieve status idle
BAUDCONbits.BRG16 = 0; // 0 - 8 bit mode, 1 - 16 bit mode
BAUDCONbits.WUE = 0; // Rx pin is not monitored
BAUDCONbits.ABDEN = 0; // Baud rate measurement disabled.
PIR1bits.TXIF = 0;
PIE1bits.TXIE = 0; // Disable intrrupts
IPR1bits.TXIP = 0;
}
main()
{
...
..
OSCCON = 0x72;
OSCTUNEbits.PLLEN = 1; // PLL enabled
init_uart();
....
....
while(1)
{
if(flag_clock == 1) // flag raised every sec
{
LATAbits.LATA0 = ! LATAbits.LATA0;
printf((const rom far char *) "\n\r%d.%d.%d", SystemTime.Hours, SystemTime.Minutes, SystemTime.Seconds);
flag_clock = 0;
}
}
}
Last edited: