From: <gl...@re...> - 2007-02-02 16:33:03
|
Hello, Are there any "usable" examples that illustrate the usage of amforth with microcontrollerspecific tasks? just to get a glimpse on it a simple timerbased port high/low thingy woul= d be nice. i could not find that usefull examples on the projects webpage. only fragments. would amforth be usable for things like the example on the bottom of this email too? (a simple servocontroller utilizing 2 timers and powermanagement. atmega16@16Mhz) btw. id like to use amforth to build a reconfigurable scheduler with an external rtc as timekeeper. thanks gerald static void io_init(void) { PORTA =3D 0x0; DDRA =3D 0x0; PORTB =3D 0x0; DDRB =3D 0xff; PORTC =3D 0x0; DDRC =3D 0x0; PORTD =3D 0x0; DDRD =3D 0x0; ACSR =3D 0x80; } void timers_init(void) { //timer0 OCR0 =3D 160; TCNT0 =3D 96; SET_BIT(TCCR0,CS00); SET_BIT(TIMSK,TOIE0); // timer0 overflow als interruptquelle SET_BIT(TCCR0,WGM00); //fast PWM SET_BIT(TCCR0,WGM01); //timer1 OCR1A =3D 50000; OCR1B =3D 50000; TCNT1 =3D 60550; TCCR1A =3D 0x00; TCCR1B =3D 0x02; //timer1 -prescaler SET_BIT(TCCR1B,CS10); SET_BIT(TIMSK,TOIE1); // time1 overflow als interruptquelle } SIGNAL(SIG_OUTPUT_COMPARE0) { static unsigned int counter; PORTB =3D 0xff; counter++; if (counter >=3D 130) { PORTB =3D 0x00; CLEAR_BIT(TIMSK,OCIE0); TCNT1 =3D 60550; SET_BIT(TIMSK,TOIE1); counter =3D 0; } } SIGNAL(SIG_OVERFLOW1) { cli(); CLEAR_BIT(TIMSK,TOIE1); SET_BIT(TIMSK,OCIE0); sei(); } int main(void) { io_init(); timers_init(); sei(); set_sleep_mode(SLEEP_MODE_IDLE); while(1) { sleep_mode(); } } |