techy_yake
Joined: 07 Feb 2010 Posts: 2
|
how to call a function in main |
Posted: Tue Feb 23, 2010 7:29 am |
|
|
Hi everyone. Hope you guys can help me here. I worked with RTC DS1307 and its working fine but when I get to call a function in the void main, my RTC won't tickle anymore.
Here is my sample code:
Code: |
void main()
{
//enable_interrupts(GLOBAL);
port_b_pullups(TRUE);
lcd_init();
kbd_init();
gca_ds1307_regs[DS1307_SECONDS_REG] = 30; // 30 seconds
gca_ds1307_regs[DS1307_MINUTES_REG] = 59; // 59 minutes
gca_ds1307_regs[DS1307_HOURS_REG] = 23; // 11 PM
//gca_ds1307_regs[DS1307_DAY_OF_WEEK_REG]= 0; // Skip this.
gca_ds1307_regs[DS1307_DATE_REG] = 22; // 22th
gca_ds1307_regs[DS1307_MONTH_REG] = 02; // February
gca_ds1307_regs[DS1307_YEAR_REG] = 10; // 2010
ds1307_set_date_time();
while(1)
{
delay_ms(1000);
ds1307_read_date_time();
// Get these into variables with shorter names, so I can
// put them into printf more easily.
sec = gca_ds1307_regs[DS1307_SECONDS_REG];
min = gca_ds1307_regs[DS1307_MINUTES_REG];
hrs = gca_ds1307_regs[DS1307_HOURS_REG];
day = gca_ds1307_regs[DS1307_DAY_OF_WEEK_REG];
date = gca_ds1307_regs[DS1307_DATE_REG];
month = gca_ds1307_regs[DS1307_MONTH_REG];
yr = gca_ds1307_regs[DS1307_YEAR_REG];
printf(lcd_putc, "\n\%02d:\%02d:\%02d", hrs,min,sec);
room_controller();
}
//disable_interrupts(GLOBAL);
}
|
Here is the function i am to call:
Code: |
//===========================================//
// room controller //
//===========================================//
void room_controller(void)
{
lcd_gotoxy(1,2);
printf(lcd_putc, "PERSONS:%d ", persons);
while(1)
{
if(input(SENS_IN)){
while(input(SENS_IN));
while(!input(SENS_OUT));
while(input(SENS_OUT));
persons++;
OUTPUT_HIGH(DEVICE);
lcd_gotoxy(1,2);
printf(lcd_putc, "PERSONS:%d ", persons);
delay_ms(600);
}
else if(input(SENS_OUT))
{
while(input(SENS_OUT));
while(!input(SENS_IN));
while(input(SENS_IN));
if(persons>0){
persons--;
lcd_gotoxy(1,2);
printf(lcd_putc, "PERSONS:%d ", persons);
delay_ms(600);}
else if(persons==0){
OUTPUT_LOW(DEVICE);
lcd_gotoxy(1,2);
printf(lcd_putc, "PERSONS:%d ", persons);
delay_ms(600);}
}
}
}
|
How can I call other function without interrupting my RTC?
thanks in advance!!! |
|