/*******************************************************
This program was created by the
CodeWizardAVR V3.18 Evaluation
Automatic Program Generator
Copyright 1998-2015 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 25/09/2024
Author :
Company :
Comments:
Chip type : ATtiny85
AVR Core Clock frequency: 8,000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 128
*******************************************************/
#include <io.h>
#include <delay.h>
// Declare your global variables here
void SetBit(unsigned char p);
void ClearBit(unsigned char m);
unsigned int i;
void main(void)
{
// Declare your local variables here
// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=(1<<CLKPCE);
CLKPR=(0<<CLKPCE) | (0<<CLKPS3) | (0<<CLKPS2) | (0<<CLKPS1) | (0<<CLKPS0);
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
// Input/Output Ports initialization
// Port B initialization
// Function: Bit5=In Bit4=In Bit3=Out Bit2=In Bit1=In Bit0=In
DDRB=(0<<DDB5) | (0<<DDB4) | (1<<DDB3) | (0<<DDB2) | (0<<DDB1) | (0<<DDB0);
// State: Bit5=T Bit4=0 Bit3=T Bit2=P Bit1=T Bit0=T
PORTB=(0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (1<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);
while (1)
{
/* // clignotement suivant action sur PINB.4
if (PINB & (1<<PINB4))
{
if (i<=10) {
SetBit(PORTB3); //Bit Port3 à 1 mettre PORTB3 qui correspond 3 OU mettre 3
delay_ms(500);
ClearBit(PORTB3);
delay_ms(500);
}
else {
SetBit(PORTB3); //Bit Port3 à 1 on peut mettre PORTB3 qui correspond 3 OU mettre 3
delay_ms(10);
ClearBit(PORTB3);
delay_ms(150);
}
i++;
}
else
{
SetBit(PORTB3); //Bit Port3 à 1 mettre PORTB3 qui correspond 3 OU mettre 3
delay_ms(150);
ClearBit(PORTB3);
delay_ms(50);
i=0;
}
*/
// Signal p riodique
PORTB.3=~PORTB.3; // PORTB.3 correspond la valeur en sortie
delay_ms(50);
/* // Utilisation de Set et Clear Bit
SetBit(PORTB3); //Bit Port3 à 1 mettre PORTB3 qui correspond 3 OU mettre 3
delay_ms(5);
ClearBit(PORTB3);
delay_ms(150);
*/
}
}
void SetBit(unsigned char p) //Ici pour mettre un bit du PortB à 1.
{
PORTB |= (1 << p);
}
void ClearBit(unsigned char m) //Ici pour mettre un bit du PortB à 0.
{
PORTB &= ~(1 << m);
}