abdosat2000
New Member
Please help in the language C ?..
I have this design.
I have this design.
LCD CLOCK
**broken link removed**This program, which I write .
Code:
#include <mega16.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18
#endasm
#include <lcd.h>
// Declare your global variables here
void main(void)
{
// Port A
PORTA=0x00;
DDRA=0x00;
// Port B
PORTB=0x00;
DDRB=0x00;
// Port C
PORTC=0x00;
DDRC=0x00;
// Port D
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: TOSC1 pin
// Clock value: PCK2/128
// Mode: Normal top=FFh
// OC2 output: Disconnected
TCCR2=0x05;
ASSR=0x08;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
GICR=0x00;
MCUCR=0x00;
MCUCSR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
// Analog Comparator Output: Off
ACSR=0x80;
SFIOR=0x00;
// LCD module initialization
lcd_init(16);
while (1)
{
// Place your code here
};
}
struct TIME_DATE {
int hour;
int minute;
int second;
int month;
int day;
int year;
} time;
bit editing; // Time being edited flag
// return max day for a given month ..
const char flash MAX_DAY[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
// Timer 2 overflow interrupt service routine ..
// This is used to keep ( Real Time ) and happens every 1 second ..
interrupt [TIM2_OVF] void timer2_ovf_isr (void)
{
if ( editing ) // time is being edited.. so don't update it!!
return ;
if ( ++time.second > 59 ) // count up seconds
{
time.second = 0; // enough for a minute?
if ( ++time.minute > 59 )
{
time.minute = 0; // enough for a hour?
if ( ++time.hour > 23 )
{
time.hour = 0; // enough hours for a day?
if ( ++time.day > MAX_DAY )
{
time.day = 1; // enough days for this month?
if ( ++time.month > 12 )
{
time.month = 1; // another year gone by..
if ( ++time.year )
{
time.year = 1;
}
}
}
}
}
}
}
I am not as good language c .
I am a junior in this area ( language c )
Please help
Please explain how to deal with the keys in the program and also the presentation on the screen
I use software CodeVisionAVR C
Thank you...