Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] OSC PLL doesnt work !

Status
Not open for further replies.

Raady Here

Full Member level 5
Full Member level 5
Joined
Jun 8, 2013
Messages
242
Helped
26
Reputation
52
Reaction score
26
Trophy points
28
Location
India
Visit site
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
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:

Hi,

is your clock frequency precise enough to run an UART?

maybe you need a chrystal clock source.

Klaus
 

In section 2.6.4, of data sheet it was mentioned that we can use internal oscillator using pll mode.
UART is running but enabling of PLL is nto showing any effect. is that the right way to enable PLL in the code menitoned above ?
 

Hi,

i´m not familiar with pic, but usually one need a clock divider to generate the UART clock from system clock.

9600Hz is no integer divider of 8MHz, so you are a bit off frequency.
If there is an additional frequency deviation of internal clock, then you may see garbage with transmitted data.

"you can use..." maybe you need a frequency calibration....

do you have a scope by hand to measure the bit timimg.
it should be 104.2 us per bit +/- 1.5us if i´m remembering right.

with 8 N 1 you transmit 10 bits per byte: so you need to have 1042 us from beginning of start bit to end of stop bit. +/- 15us

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top