QY4A with crystal oscilator

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

QY4A with crystal oscilator

1,809 Views
admin
Specialist II
Hi,
 
    Could anyone send me how to configure (an example in C or Assembly) QY4A to work with external crystal oscilator (20MHz)?
   
 
Thanks a Lot
 
Edson
Labels (1)
0 Kudos
4 Replies

355 Views
Ake
Contributor II
Hi,
Here is the code that is required when using the oscillator module in the HC908QY4A.
 
It shows how to use the internal or external oscillator.
 
The frequencies that I have got in internal mode, is because I have not used the calibration value.
I have not found the external oscillator value, but it ought to be somewhere close to 19.6 MHz.
 
I have seen that the other guys have added delays after switching the oscillator, to switching the generator. I have not done it, perhaps you should add it.
 
I have used the Bunker M68EVB908Q demo board with the original HC908QY4 replaced by a HC908QT4A device.
 
Regards,
Ake
0 Kudos

355 Views
bigmac
Specialist III
Hello Edson,
 
Are you actually attempting to use a crystal oscillator, or an external crystal?  They are not the same.  The four step procedure to switch from the internal clock, to an external clock, is detailed within paragraph 11.3.2.2 of the data sheet.  Is there anything you do not understand about this process?
 
Regards,
Mac
 
0 Kudos

355 Views
admin
Specialist II
Hi Mac,
 
        I follow the datasheet and Processor Expert but the chip continues without clock signal.
        The code that I'm using is: 
 
 
 
 
; clock inicialization
 
        ; CONFIG1: COPRS=0,LVISTOP=0,LVIRSTD=0,LVIPWRD=0,LVITRIP=0,SSREC=0,STOP=0,COPD=1
        MOV     #$01,CONFIG1                                       
        ; CONFIG2: IRQPUD=0,IRQEN=0,OSCENINSTOP=0,RSTEN=0
        CLR     CONFIG2 
       
        bclr 7,OSCSC
        bset 6,OSCSC
       
        bset 5,DDRA ;OSC2
        bset 5,PTA ;TESTE
       
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
              
       
                                                    
        ; OSCSC: OSCOPT1=1,OSCOPT0=1,ICFS1=1,ICFS0=0,ECFS1=0,ECFS0=0,ECGON=0,ECGST=0
        MOV     #$E0,OSCSC                                       
        ; Wait
        LDHX    #0                     ; Main delay counter
for_delay0:
        LDA     #5                     ; Delay code 
for_delay_A_0:
        DECA                           ; Delay code
        BCC     for_delay_A_0          ; Delay code
        AIX     #1
        CPHX    #CGM_DELAY
        BNE     for_delay0
        ; Enable External Clock Generator
        ; OSCSC: ECGON=1
        BSET    $01,OSCSC
while_Cpu0:                            ; Wait for external oscillator stabilization
        BRCLR   0,OSCSC,while_Cpu0              
 
 
        I don't know where is the mistake.
 
 
Thanks a lot.
 
Edson
 
                       
                      
0 Kudos

355 Views
bigmac
Specialist III
Hello Edson,
 
The problem with your sample code is almost certainly because of a bug in your delay code - the operation will loop continuously prior to the code to switch to the external clock, and you have also disabled the COP timer.  The carry flag does not ever change as a result of a DEC instruction.
 
Some simple code to provide a suitable crystal stabilization delay might be as follows -
 
       lda   #5   ; Delay is multiple of 771 cycles
       clrx
LOOP1: dbnzx LOOP1
       dbnza LOOP1
 
I suspect that, had you observed the waveform at one of the crystal pins, the clock signal should have been present after you enabled the external crystal.  This also assumes that you do not have a faulty crystal.
 
Regards,
Mac
 
0 Kudos