We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.
If the symbol is undefined, it may be caused by the Keil header files either not containing the symbol - or spelling it slightly different because of a name change between different processors in the same family.
You can define the symbol yourself - the datasheet for your chip clearly states what address this bit or byte is at.
Its a bit. I have tried "OSCXCN.7" too. It says: "Invalid Byte Base in Bit Address Expression". But I'm sure that it is in bit 7.
See here: http://www.keil.com/support/docs/1916.htm
SILabs provides an excellent program named config(2) that creates all the code you need, why do you refuse to use it?
Erik
I see... I didn't know how to use though. Thanks for the info though. I'll try this config(2)..
"I have tried "OSCXCN.7" too. It says: 'Invalid Byte Base in Bit Address Expression'. But I'm sure that it is in bit 7."
The "Base Address" refers to the "OSCXCN" part - not the "7"
It is telling you that "OSCXCN" is not a valid Byte Base for a Bit Address. Are you sure that "OSCXCN" is bit-addressable?
You (the OP) need to study "the bible", in particular pay attention to the little note at the bottom of fig2 in ch3
here are the links to "the bible" Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer’s Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
From what i read in the "bible", it is not bit addessable. Only the most left hand column of the SFR memory map are bit addressable. Am i right? And from the datasheet i found out that the address for the byte is at B1.
Does this means that bit 1 of OSCXCN is located at b1? and bit 7 of OSCXCN is located at b7?
MOV R1,OSCXCN WAIT1:CJNE R1,#80H,WAIT1
Isit advisable to use the above code?
I can run using the above code. But whenever i run, it will hang at the 1st line when it runs to the oscillator config routine.
This is my oscillator routine.
MOV OSCICN,#08H ; Disable internal oscillator & enable external oscillator ACALL DELAY MOV R1,OSCXCN WAIT1:CJNE R1,#80H,WAIT1 ; poll to see whether crystal is ready MOV OSCXCN,#32H ; config external crystal
Does it have something to do with my crystal or my programming?
Don't you think that you have to continuously read the value from OSCICN in you wait loop?
Why do i have to continously read value from OSCICN in my "wait" loop? OSCICN does not have any bits for me to poll. All the bits in OSCICN have been configured.
your wait-loop is going to loop untill OSCICN equals exactly 0x80. you want to mask the other bits and then test for bit 7. You could do a 'bitwise AND' of 0x80 and OSCICN, if the value is not zero then bit 7 is set.
OSCXCN you mean? Can you explain it in simpler terms? I can't really get you.
Since OSCXCN is not bit-addressable you need to use a different method of testing bit7. You should learn about bitwise operations; en.wikipedia.org/.../Bitwise_operation
MOV R1, OSCXCN ; Copies the current value from OSCXCN to R1 WAIT1: CJNE R1, #80H, WAIT1 ; Continually checks R1
If the value in OSCXCN changes, how will that affect R1 in your loop?