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.
The DS1642 is an RTC + NVRAM The information is in centain memory locations in bcd format. Ok , so i made a simple program to display the minutes :
#include <reg51.h%gt; xdata minutes _at_ 0x07FA; //this is the memory location containing minutes xdata control _at_ 0x07F8; //this is the control reg void main() { while(1) { control = 0x40; //set the read bit putchar(13);putchar(10);putchar('m');putchar('='); //eye candy punchar(minutes); control = 0x00; //reset the read bit delay(100); } }
Give this a try:
volatile xdata minutes _at_ 0x07FA; volatile xdata control _at_ 0x07F8;
How does this work?
volatile xdata token_num _at_ 0x0010;
"What is the data type here?" In 'C', eveything is an int unless otherwise specified.
Yes, I missed the fact that a data type was not specified. Making the address volatile insures that the generated code will read the minutes location each pass in your while loop. -Walt
"Yes, I missed the fact that a data type was not specified." probably because that's how it was in the original post?