[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] AVR butterfly Timer1
From: |
Dave |
Subject: |
[avr-gcc-list] AVR butterfly Timer1 |
Date: |
Mon, 13 Feb 2006 11:50:44 -0800 (PST) |
Hello!
Instead of the 8-bit timer/counter, I decided to use
the 16-bit one. Now, I'm having trouble with timer1 on
my AVR butterfly. I'm trying to print the counted
ticks on the LCD, but nothing shows up on the LCD. The
following is my code:
// initiliaze timer/counter1
void Timer_Init()
{
cli(); // disable interrupts
TCCR1A = 1; // internal clock will be used
TCCR1B = 1;
TCNT1 = 0; // start timer
sei();
}
// read timer1
unsigned int Timer_Read() {
unsigned int i;
cli();
i = TCNT1;
sei();
return i;
}
int main(void)
{
PGM_P statetext;
char LCD_table[10] =
{'0','1','2','3','4','5','6','7','8','9'};
unsigned int i, t;
// Initial state variables
statetext = PSTR("DONE");
LCD_Init();
sei();
Timer_Init();
foo();
t = Timer_Read();
LCD_puts_f(statetext, 0);
Delay(30);
for (;;) {
if (t < 10)
LCD_putc(0, LCD_table[t]);
else if (t < 100) {
i = t / 10;
LCD_putc(0, LCD_table[i]);
i = t % 10;
LCD_putc(1, LCD_table[i]);
}
else if (t < 1000) {
i = t / 100;
LCD_putc(0, LCD_table[i]);
i = (t % 100) / 10;
LCD_putc(1, LCD_table[i]);
i = (t % 100) % 10;
LCD_putc(2, LCD_table[i]);
}
....
....
}
return 0;
}
Without the timer operations, "DONE" shows up on the
LCD when foo() finishes. When the timer operations are
included, nothing shows up on the LCD, not even
"DONE". Any help on this matter will be greatly
appreciated. Thank you.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] AVR butterfly Timer1,
Dave <=