replace START_WAIT timer with simple loop

This commit is contained in:
Olaf Rempel 2006-05-26 19:54:29 +02:00
parent 93453d0aaa
commit 0cbb5686dc

43
main.c
View File

@ -84,11 +84,14 @@
* WAIT-mode waits 1 sec for the S command if nothing is recived
* then the user prog is started ..
*/
#define START_SIMPLE
//#define START_WAIT
//#define START_SIMPLE
#define START_WAIT
//#define START_POWERSAVE
//#define START_BOOTICE
/* wait 1s in START_WAIT mode (10ms steps) */
#define WAIT_VALUE 100
/*
* enable/disable readout of fuse and lock-bits
* (will not work for Mega169 since not supported by AVRPROG 1.37
@ -109,6 +112,7 @@
#include <avr/wdt.h>
#include <avr/boot.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "chipdef.h"
@ -324,43 +328,20 @@ int main(void)
#elif defined(START_WAIT)
// Timer-Setup for ATmega8
// - verify that the configuration is valid for the target AVR
#define MY_WAIT 900
// wait ca 1 sec (900ms)
TCCR1A = 0; // timer setup
// F_OSC / 8 / 1000 -> 1ms
#if (((F_CPU / 8 / 1000)*MY_WAIT) < 65535)
#warning Information: setting prescaler to 8
#define WAIT_VALUE ((F_CPU / 8 / 1000)*MY_WAIT)
TCCR1B |= (1<<CS01);
#elif ((((F_CPU / 64 / 1000)*MY_WAIT) < 65535))
#warning Information: setting prescaler to 64
#define WAIT_VALUE ((F_CPU / 64 / 1000)*MY_WAIT)
TCCR1B |= (1<<CS01) | (1<<CS00);
#elif ((((F_CPU / 256 / 1000)*MY_WAIT) < 65535))
#warning Information: setting prescaler to 256
#define WAIT_VALUE ((F_CPU / 256 / 1000)*MY_WAIT)
TCCR1B |= (1<<CS02);
#else //((((F_CPU / 1024 / 1000)*MY_WAIT) < 65535))
#warning Information: setting prescaler to 1024
#define WAIT_VALUE ((F_CPU / 1024 / 1000)*MY_WAIT)
TCCR1B |= (1<<CS00) | (1<<CS02); //1024 prescaler
#endif
uint16_t cnt = 0;
while (1) {
if (UART_STATUS & (1<<UART_RXREADY)) {
if (UART_STATUS & (1<<UART_RXREADY))
if (UART_DATA == 'S')
break;
}
if (TCNT1 >= WAIT_VALUE){
if (cnt++ >= WAIT_VALUE) {
BLPORT &= ~(1<<BLPNUM); // set to default
TCCR1B = 0; // timer off
jump_to_app(); // Jump to application sector
}
_delay_ms(10);
}
TCCR1B = 0; // timer off
send_boot();
#elif defined(START_BOOTICE)