[avrgcc] How can I save 23 into address 00 ?

Status
Not open for further replies.

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
Visit site
Activity points
9,442
Guys,

I want to set alarm from my EEPROM and compare it to current time on RTC .
How can I save 23 into address 00 ? ---> hour 23, 23:00
I used ATMEGA128
I've done :
Code:
      unsigned char alarm_hour;
                                   alarm_hour++;
				   
				   if (alarm_hour >= 23)
				   {
					   alarm_hour = 0;
				   }
				   
				   
				   uint8_t ByteOfData ;
				   ByteOfData = alarm_hour ;
				   eeprom_update_byte (( uint8_t *) 00, ByteOfData );

Thanks for reading and helping
 

Re: How can I save 23 into address 00 ?

I guess you are referring to a specific AVR compiler and library? And you want only answers from Edaboard members that know these particular tools?

Good luck!
 

Re: How can I save 23 into address 00 ?

for storing a value of a variable

Code C - [expand]
1
eeprom_update_byte (( uint8_t *) 00, ( uint8_t) alarm_hour );

 

Re: How can I save 23 into address 00 ?

I'm using atmel studio
How can I display "alarm_hour" to LCD, do I need printf ?
Code:
Code:
			  case SET_ALARM_HOUR: //Set alarm hour
			  //set hour alarm
			  lcd_xy(0,0);//put on 0,0
			  lcd_string("SET HOUR ALARM ");
			  lcd_cmd(0xC0);
			  lcd_string(alarm_hour);
			  lcd_string("  ");
			  button_input = button_is_pressed();//read button
			  
			  if (button_input==1)
			  {
				  tone(50);
				  _delay_ms(50);
				  tone(0);
				  state_var = DISPLAY_TIME;
			  }
			  
			   if (button_input==2) // //  if button 2 pressed ( button up)
			   {
				   alarm_hour++;
				   tone(50);
				   _delay_ms(50);
				   tone(0);
				   if (alarm_hour >= 23)
				   {
					   alarm_hour = 0;
				   }
				   
				   
				   
				   eeprom_update_byte (( uint8_t *) 00, alarm_hour );
				   state_var = SET_ALARM_HOUR;
			   }
			   
			    if (button_input==3) // //  if button 3 pressed ( button up)
			    {
				    tone(50);
				    _delay_ms(50);
				    tone(0);
				    state_var = BATTERY_STATUS;
			    }
			  
			  break;
 

Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…