This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help with external crystal...

Hi guys. I changed my board to C8051F226 already and i'm using a 32.768kHz external crystal. I have read the datasheet for the oscillator. But i do not understand this sentence, can someone please explain it to me?

"Crystal Oscillator Mode with divide by 2 stage."

The datasheet also recommend me to do the following:

1.Enable the external oscillator
2.Wait 1 ms
3.Poll for XTLVLD '0' ==> '1'
4.Switch to the external oscillator

I have done the 1st 2 steps, but i can't seem to poll for XTLVLD. When i compile, it says undefined symbol.

Parents Reply Children
  • I tried it. and it works fine... thanks...

  • What does this sentence means?

    "Crystal Oscillator Mode with divide by 2 stage."

    Does this means that the crystal frequency is divided by 2?

  • I tried debugging my code... But the LCD only display "000 BPM".
    I took a sample of 5 seconds to get the pulses. I read through my code and found all of it logical (from my knowledge). Anyone can help me to find out the problem?
    Here is my timer and oscillator code:

    
    MOV OSCXCN,#062H        ; External Oscillator Control Register
    CLR A            ; Clear value of Accumulator
    DJNZ ACC,$      ; Wait for
    DJNZ ACC,$      ; at least 1ms
    
    OX_WAIT:        MOV A,OSCXCN ; Move data in OSCXCN to Accumulator
    JNB ACC.7,OX_WAIT ; Poll XTLVLD
    MOV OSCICN,#008H        ; Internal Oscillator Control Register
    
    
    MOV IE,#8CH
    MOV IP,#04H
    
    SETB TCON.2
    MOV TMOD,#10H
    MOV CKCON,#000H
    
    
    ;*************
    ;-Start Timer-
    ;*************
    START:  MOV TH1,#0C9H
            MOV TL1,#50H  ; Program timer to run for 5 seconds
            MOV R3,#00H
            SETB TR1             ; Start timer
    ;****************************
    ;-Timer 1 Overflow Interrupt-
    ;****************************
    T1_INT: CLR TF1 ; Clear overflow flag
            MOV TH1,#0C9H
            MOV TL1,#50H
            RETI
    
    ;**********************
    ;-External Interrupt 1-
    ;**********************
    EX_INT1:   INC R3       ; Increment R3
               MOV A,R3 ; Move data in R3 to Accumulator
              RETI
    

    After this, i use a routine to convert binary HEX to ASCII and display.