Problem selecting external crystal as clock source

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem selecting external crystal as clock source

1,994 Views
pallavaggarwal
Contributor I
hi,
I want to run my controller QB8 using external crystal 4.9152MHz
and not using internal
i have used the following code as atest but after removing thr crystal also i get the pulses on PTB0 .
 
please check my code and guide me how to use the external cystal as clock
source
 
this program just makes on/off PTB0
 
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908QB8.h> /* include peripheral declarations */

//macro defination for BIT wise manupulation
#define setbit(A,B) A|=(1<<B)
#define clrbit(A,B) A&=~(1<<B)

void main(void)
{

unsigned char a=0,i=0;
OSCSC=0xC4;
CONFIG1=0x01;//Disable COP
DDRA=0x10;
DDRB=0xFF;
while(1)
{
PTB=0x01;
for(i=0;i<100;i++);
PTB=0x00;
for(i=0;i<100;i++);
}
}
 
Labels (1)
0 Kudos
1 Reply

241 Views
peg
Senior Contributor IV

Hi pallav,

It appears to me that you should write 0xC4 to OSCSC.

Then wait about 1ms to stabilise.

Then set ECGON in OSCSC.

Then shortly after you should be running on ext xtal.

Refer to 11.3.2.2 of QB8 datasheet.

Regards David

 

0 Kudos