Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ATMEGA16 with Real time clock

Status
Not open for further replies.

Kaze105

Junior Member level 1
Junior Member level 1
Joined
Aug 13, 2010
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,411
I am hoping to connect a real time clock to the ATMEGA16. A 32.XX (forgot exact number) Khz crystal oscillator is connected to the ports of TOSC1 and TOSC2.

I am using codevisionAVR to program the ATMEGA16 using a development board.

I am having trouble displaying the time onto the LCD display (which displays other things just fine).

I am hoping someone could help me with the coding for this.

I also do have a DS1672-33 external real time clock, but have yet to use it due to being unsure how to program it properly.

(In simple, hardware connections are just fine, i just need help with the coding using codevision AVR.)
 

Could you post your code rather than simply asking your problem so that everyone can give solution... Timer/Counter2 can be used as asynchronous communication [RTC] by setting AS2 bit in ASSR[Asynchronous status register] register..
 
Here is the code within the main(void)

Code:
 // Timer/Counter 2 initialization 
 // Clock source: TOSC1 pin 
 // Clock value: PCK2/128 
 // Mode: Output Compare 
 // OC2 output: Disconnected 
 TCCR2=0x05; 
 ASSR=0x08; 
 TCNT2=0x00; 
 OCR2=0x00;

I have it set up with the interrupt with the code below:

Code:
interrupt [TIM2_OVF] void timer2_ovf_isr(void) 
{  
       if(++time.second > 59)  // if seconds = 60 
 { 
  time.second = 0;  // set seconds to 0 
  if(++time.minute > 59)          // if minutes = 60 
  { 
   time.minute = 0; // set minutes to 0 
   if(++time.hour > 12)    // if hours = 13 
   {   
    if(dayornight == 0) // if AM 
    { 
    dayornight = 1;     // change to PM 
    } 
    else 
    dayornight = 0;     // make AM because already PM         
    time.hour = 1; // change to 1 O'clock 
                        } 
                } 
        } 
    
   /*** Definitions for printf() statements***/ 
   // 20 scroll off so when at bottom row goes to top 
   // 17 set cursor postion 
   // 4 go to column 5 
   // 3 go to row 4 
         
        if (timedisplay == 1) 
          {  
        if (dayornight == 0) 
          { 
        printf("%c%c%c%c%02u:%02u:%02u AM",20,17,4,3,time.hour,time.minute,time.second); 
          } 
            else 
              {   
                printf("%c%c%c%c%02u:%02u:%02u PM",20,17,4,3,time.hour,time.minute,time.second);  
              } 
           } 
            
           if (timedisplayset == 1)    //to display first feeding time set when setting 
          {  
        if (dayornightset == 0) 
          { 
        printf("%c%c%c%c  %02u:%02u AM",20,17,4,3,timeset.hourset,timeset.minuteset); 
          } 
            else 
              {   
                printf("%c%c%c%c  %02u:%02u PM",20,17,4,3,timeset.hourset,timeset.minuteset,);  
              } 
           } 
            
           if (timedisplayset2 == 1) 
          {  
        if (dayornightset2 == 0) 
          { 
        printf("%c%c%c%c  %02u:%02u AM",20,17,4,3,timeset2.hourset2,timeset2.minuteset2,); 
          } 
            else 
              {   
                printf("%c%c%c%c  %02u:%02u PM",20,17,4,3,timeset2.hourset2,timeset2.minuteset2,);  
              } 
           } 
         }

Code is made so that when I enter timedisplay=1; in the main(void), the time will appear on the LCD.
I know the LCD works with other simple printf statements, but when I try this, nothing is displayed onto the LCD.
 

I want to implement digital clk using seven segment display plz help me.............dear's
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top