/* Kod programu
Pomozcie w znalezieniu bledu. Moze cos jeszcze trzeba ustawic. Fusebit BOOTRST jest niezaprogramowany.
*/ #define __AVR_ATmega16__ #include <string.h>
#include "avr/eeprom.h" #include "avr/io.h" #include "avr/signal.h" #include "avr/interrupt.h"
typedef unsigned char BYTE; typedef unsigned int WORD;
BYTE a = 'a'; BYTE b = ' ' ; BYTE c = 'c'; int count = 0; void rs_init() { outp(0, UBRRH ); outp(47, UBRRL); outp(BV(RXEN)|BV(TXEN), UCSRB); //outp(BV(RXCIE)|BV(TXCIE)|BV(URSEL)|BV(UCSZ0)|BV(UCSZ1), UCSRC); outp((BV(URSEL)|BV(UCSZ0)|BV(UCSZ1)) ,UCSRC);; }
void rs_putch(BYTE c) { outp(c, UDR); loop_until_bit_is_set(UCSRA,TXC); sbi(UCSRA, TXC); } void rs_puts(char *str) { while (*str != 0) { rs_putch(*str); str++; } } BYTE rs_getch() { BYTE c = 0; loop_until_bit_is_set(UCSRA, RXC); c = inp(UDR); return c; } SIGNAL(SIG_OVERFLOW0) { count++; if(count > 100) { count = 0; if(a < 'w') a++; else a = '0'; } } SIGNAL(__vector_default) { rs_putch('d'); b = 'd'; }
int main() { outp((1<<TOIE0), TIMSK); /* enables the T/C0 overflow interrupt in the T/C interrupt mask register for */ outp(0, TCNT0); /* start value of T/C0 */ outp(5, TCCR0); /* prescale ck/1024 */ rs_init(); rs_puts("\n\rBefore sei"); sei(); rs_puts("\n\rReset"); for(;;) { if(a != c) { rs_puts("\n\ra = "); c = a; rs_putch(a); } if(b != ' ' ) { rs_puts("\n\rb = "); rs_putch(b); b = ' ' ; } } return 0; } /* A moze ktos moglby na szybko przepuscic przez avr-gcc i sprawdzic u siebie czy toto dziala. Jest moze jakis prosty symulator dla AVR pod linuxy??
Pozdrawiam Tomek
*/