Adding files
This commit is contained in:
parent
759597d8f9
commit
42bae683e1
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,31 @@
|
|||
//sinusoidal PWM using ADC(16-bit PWM to be used)
|
||||
|
||||
|
||||
|
||||
#define F_CPU 16000000//16Mhz
|
||||
#define MS_DELAY 1000
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
int main(void)
|
||||
{
|
||||
DDRB = 0xFF;//Port B set as output
|
||||
//DDRL = 0xff;//port L direction: output //pins- 49:42
|
||||
//DDRC = 0xff;//port C direction: output //pins- 37:30
|
||||
ADCSRA = 0x87;// ADC enabled and prescaler=128
|
||||
ADMUX = 0x40;// Ref= Vcc// data is right-justified //ADC0 is source pin
|
||||
while(1)
|
||||
{
|
||||
//ADIF=0 ifu wanna reset, otherwise you keep it as 1 so that conversion doesnt start again
|
||||
//ADCSRA |= (1<<ADSC); //to start conversion, we set ADSC bit to 1
|
||||
ADCSRA |= 0x40; //ADSC=1
|
||||
//while(ADCSRA && (1<<ADIF)==0);// waiting for conversion to finish
|
||||
while(ADIF==0);
|
||||
OCR1AL = ADCL;
|
||||
OCR1AH = ADCH;
|
||||
TCCR1A = 0x83;//non-inverting pwm; mode-7: 10-bit Fast PWM
|
||||
TCCR1B = 0x10;//prescaler = 8 for frequency to be approx 2kHz
|
||||
//output of pwm is at pin 13(OC0)
|
||||
_delay_ms(50);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
:100000000C9472000C947E000C947E000C947E0084
|
||||
:100010000C947E000C947E000C947E000C947E0068
|
||||
:100020000C947E000C947E000C947E000C947E0058
|
||||
:100030000C947E000C947E000C947E000C947E0048
|
||||
:100040000C947E000C947E000C947E000C947E0038
|
||||
:100050000C947E000C947E000C947E000C947E0028
|
||||
:100060000C947E000C947E000C947E000C947E0018
|
||||
:100070000C947E000C947E000C947E000C947E0008
|
||||
:100080000C947E000C947E000C947E000C947E00F8
|
||||
:100090000C947E000C947E000C947E000C947E00E8
|
||||
:1000A0000C947E000C947E000C947E000C947E00D8
|
||||
:1000B0000C947E000C947E000C947E000C947E00C8
|
||||
:1000C0000C947E000C947E000C947E000C947E00B8
|
||||
:1000D0000C947E000C947E000C947E000C947E00A8
|
||||
:1000E0000C947E0011241FBECFEFD1E2DEBFCDBF46
|
||||
:1000F00000E00CBF0E9480000C94A5000C9400004E
|
||||
:100100008FEF84B987E880937A0080E480937C0045
|
||||
:1001100023E890E180917A00806480937A00809156
|
||||
:1001200078008093880080917900809389002093E3
|
||||
:100130008000909381003FEF40E782E031504040E3
|
||||
:0E0140008040E1F700C00000E5CFF894FFCF4B
|
||||
:00000001FF
|
Binary file not shown.
Loading…
Reference in New Issue