Posts Tagged ‘avr’

programming avrs

Monday, February 8th, 2010

I have been working on avr project for almost a year now.  As I have been getitng closer to completion I have finally jumped from arduino to my own custom avr board.   Then came the problem of programming the icsp.  I tried 2 different serial and parallel programmers to no luck.  And then I thought why not use an arduino to programmer to program my avr 168p.  I tried 4 different software ones to no luck and then found this mega-isp  . works great,  I was able to flash my avr with no troubles I highly recommend it.

working with avr and pwm

Saturday, February 6th, 2010

I seemed to have a lot of trouble getting pwm code going.  below is some simple code that got me going.  looking back on it now I am unsure as to why I was having such problems.  I think its because, arduino, port codes, and timer codes, and pwm codes dont exactly match and I wasnt looking at the reference material.  anyways hope this helps.

int main (void)
{
DDRD |= (1<< PD3) | (1<< PD5) | (1<< PD6);
TCCR0A = (1<<COM0A1)|(1<<COM0B1)|(1<<WGM01)|(1<<WGM00);
TCCR0B = (1<<CS00);
TCCR2A = (1<<COM2A1)|(1<<COM2B1)|(1<<WGM21)|(1<<WGM20);
TCCR2B = (1<<CS20);
OCR0A = 0;
OCR0B = 100;
OCR2B = 255;
sei();
while (1)
{
;
}
}