Cours:TPS 2103 tp ampliAudio : Différence entre versions

De troyesGEII
Aller à : navigation, rechercher
(Page créée avec « <source lang=cpp> #include <avr/io.h> #include <util/delay.h> int main() { PLLCSR|=(1<<PINDIV)|(1<<PLLE); PLLFRQ&=~(1<<PDIV2); PLLFRQ|=(1<<PLLTM1)|(1<<PDIV3)|(1<<PDIV... »)
 
Ligne 1 : Ligne 1 :
 +
 +
<accesscontrol>Acces:Prof</accesscontrol>
 
<source lang=cpp>
 
<source lang=cpp>
  

Version du 12 février 2018 à 16:13

Il s’agit d’une page protégée.

#include <avr/io.h>
#include <util/delay.h>

int main()
{
	PLLCSR|=(1<<PINDIV)|(1<<PLLE);
	PLLFRQ&=~(1<<PDIV2);
	PLLFRQ|=(1<<PLLTM1)|(1<<PDIV3)|(1<<PDIV1);





    uint8_t time=0;
    uint8_t tabSinus[30]={127,153,179,202,221,237,248,253,253,248,237,221,202,179,153,127,101,75,52,33,17,6,1,1,6,17,33,52,75,101};
	DDRC |=(1<<PC7);
	TCCR4A|= (1<<COM4A0);
	TCCR4B|=(1<<CS40);
	TCCR4A|=(1<<PWM4A);
	OCR4C=255;
	while(1)
	{
		OCR4A=tabSinus[time];
		_delay_us(100);
		if (time==29) time=0; else time++;
	}
}