Hi - I've encountered a very wierd problem. I recently built a 32 servo controller based around an ATMEGA162. There's a servo PWM output on 32 different GPIOs. 28 of the 32 work beautifully. But 4 pins, the 4 highest bits on portc, just do not work at all. I have run a couple tests to make sure that it isn't in the software. Just in case, here's the initialization code:
/* initialize USART */ UCSR0B=1<<RXEN0|1<<TXEN0; /* no rx interrupt (1<<RXCIE0), enable tx and rx, */ UCSR0C=1<<UCSZ01|1<<UCSZ00; /* 8b character size, no parity, 1 stop bit */ UBRR0L=8; /* 115200 bps baudrate with 16mhz oscilator */ UBRR0H=0; /* initialize timer */ TCCR1B = 1<<CS11|1<<WGM12; /* prescaler = 8, clear counter on OC1A match */ OCR1A = 40000; //16e6 / (8 * 50) OCR1B = 5130; /* 620-5640 */ TIMSK = 1<<OCIE1A|1<<OCIE1B; /* enable OC1A interrupt */ DDRA = 0xFF; DDRB = 0xFF; DDRC = 0xFF; DDRD = 0xFC; DDRE = 0x07; sei ();
I have confirmed that everything is soldered properly and that there is a physical connection between these 4 pins on the atmega162 and the output header. So it doesn't seem to be software *or* hardware.
Anybody have any clue what could be going wrong here? I'm just completely lost here.
PS by the way, notice I had to write the UBBR0 high and low bytes seperately? I'm using I believe the latest WinAVR. I used similar code on an ATMEGA48, and I always just wrote to UBRR0 - the compiler took care of the high and low bytes for me. But when I tried to do the same with this atmega162 gcc spit out errors at me. Wierd.