J'attendrai donc avec impatience vos suggestions, le temps que je coggitte tout ca dans mon coin.
Merci d'avance les loulous.
Modérateur: Modérateur
#include <avr/io.h>
#include <avr/interrupt.h>
unsigned char count;
int main(void)
{
DDRB = 0X07;
PORTB = 0X00;
TCCR1B |= (1 << WGM12) | (1 << CS12);//set only (1 << CS12) for prescaler 256
sei();//enable globale interrupts
TIMSK |= (1 << OCIE1A);//enable output compare A
OCR1A = 39062;//CTC value to 1HZ @ 8MHZ(AVR clk)
}
ISR(TIMER1_COMPA_vect)
{
for (count=5;count=0;count--)
{
if(count==0)
{
PORTB ^=(1 << PB1);
}
PORTB ^= (1 << PB0);//toggle LED
}
while(1);
}
#include <avr/io.h>
#include <avr/interrupt.h>
int i=5;
int main(void)
{
DDRB = 0X03;//3first bits as outputs
TCCR1A |= ((1 << COM1A1) | (1 << COM1A0));
TCCR1B |= ((1 << WGM12) | (1 << CS12)); //settings for prescaler 256 and CTC mode
sei(); //enable globale interrupts
TIMSK |= (1 << OCIE1A); //enable output compare A
OCR1A = 39062; //CTC value to 1HZ @ 8MHZ(AVR clk)
return 0;
}
ISR(TIMER1_COMPA_vect)
{
i--;
if(i==0)
{
PORTB ^= (1 << PB1);
i=5;
}
PORTB ^= (1 << PB0); //toggle LED 1 sec
}
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités