bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
Guys,
I want to ask about multitasking on ATMEGA128,
I have written the code below, but there's no response on my LCD, every ideas will be appreciated, thanks
Do I put the right call on main ?
I didn't see any response on LCD....
Did I miss something here ?
I want to ask about multitasking on ATMEGA128,
I have written the code below, but there's no response on my LCD, every ideas will be appreciated, thanks
Code:
void task0(void)
{
typedef enum {
DISPLAY_TIME,
SET_WEEK_DAY,
SET_MONTH,
GO_BACK
} my_states;
//static uint8_t state;
static my_states state_var = DISPLAY_TIME;
int button_input;
switch (state_var) {
DISPLAY_TIME :
display_time();//display time
button_input = button_is_pressed();//read button
if (button_input==1)//if button pressed, state = b;
{
state_var = SET_WEEK_DAY;
}else //else
{
display_time();//read ds1307 into time structure
//read time struct and display on lcd
}
break; // break;
SET_WEEK_DAY: //set date
lcd_cmd(0x01);//clear lcd
lcd_cmd(0x0F);//view cursor
lcd_xy(0,0);//put in the position 0,0 to edit
_delay_ms(250);
lcd_string("Enter new day:");
lcd_xy(1,0);
lcd_string(weekday[ds1307_addr[3]]);//display day of the week
lcd_xy(1,0);//return the cursor to the front
button_input = button_is_pressed();//read button
if (button_input==2) //if button 2 pressed
{
lcd_string(weekday[ds1307_addr[3]+1]);//increase day of the week
}
state_var = SET_MONTH;
break;
SET_MONTH:
state_var =GO_BACK;
break;
GO_BACK:
state_var = DISPLAY_TIME;
break;
default:
break; //default
}//end of switch
task_timers[0] = 10; //every 100ms
reset_task(0);
}
Code:
int main(void)
{
// start at least one task here
//
set_task(0); //task0 runs display the time
set_task(1); //put tick on output
// main loop
while(1)
{
if (tick_flag)
{
tick_flag = 0;
task_dispatch(); // well....
}
}
}
I didn't see any response on LCD....
Did I miss something here ?