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
  • "Just sidetracking a bit."

    That's not just "a bit" that's a totally different and unrelated question!
    It's also nothing to do with Keil tools so, strictly, it's off-topic - it's actually an analogue electronic design question.
    You should go to the ADC manufacturers' websites for stuff like this - they have tons of stuff on it!
    Try TI, National Semiconductor, Analog Devices, Linear Technology, Maxim, et al...

    "How do i make 2 inputs from 2 sensor go into 1 ADC"

    You need a Multiplexer; there are plenty of ADCs available with these built-in - including some integrated with 8051 controllers.
    Again, look on the ADC manufacturers' websites.

    "by comparing the signals to determine ... which signal is better"

    Before you can do that, you need to define exactly what constitutes "better" for your application.

    "Better" on its own like that is totally meaningless!

Reply
  • "Just sidetracking a bit."

    That's not just "a bit" that's a totally different and unrelated question!
    It's also nothing to do with Keil tools so, strictly, it's off-topic - it's actually an analogue electronic design question.
    You should go to the ADC manufacturers' websites for stuff like this - they have tons of stuff on it!
    Try TI, National Semiconductor, Analog Devices, Linear Technology, Maxim, et al...

    "How do i make 2 inputs from 2 sensor go into 1 ADC"

    You need a Multiplexer; there are plenty of ADCs available with these built-in - including some integrated with 8051 controllers.
    Again, look on the ADC manufacturers' websites.

    "by comparing the signals to determine ... which signal is better"

    Before you can do that, you need to define exactly what constitutes "better" for your application.

    "Better" on its own like that is totally meaningless!

Children
  • I see... Thanks for the info. So the code above can be used?

  • So the code above can be used?

    Have you tested? Wouldn't a very simple test answer your question?

  • 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.