Go Down

Topic: code running with ATMEGA328, not with ATMEGA168  (Read 366 times) previous topic - next topic

RIN67630

Hi,
I have got a dozen of Arduino mini Pro clones havin an ATMEGA168 instead of the ATMEGA328.

My code compiles without error and loads once I have changed the processor type to ATMEGA168 7 3,2V 8MHz.
Sketch uses 8138 bytes (56%) of program storage space. Maximum is 14336 bytes.
Global variables use 420 bytes (41%) of dynamic memory, leaving 604 bytes for local variables.
Maximum is 1024 bytes.

But it does not run, like it does on the ATMEGA328.

Can it be that the interrupt processing is another one?

Code: [Select]
  //set timer2 interrupt at 2kHz
  TCCR2A = 0;// set entire TCCR2A register to 0
  TCCR2B = 0;// same for TCCR2B
  TCNT2  = 0;//initialize counter value to 0
  // set compare match register for 2khz increments
  OCR2A = 249;// = (16*10^6) / (2000*32) - 1 (must be <256)
  // turn on CTC mode
  TCCR2A |= (1 << WGM21);
  // Set CS20 , CS 21 and CS22 bit for 128 prescaler
  TCCR2B |= (1 << CS22) | (0 << CS21) | (1 << CS20);
  // enable timer compare interrupt
  TIMSK2 |= (1 << OCIE2A);
 
  sei();//allow interrupts



RIN67630

The code dis run indeed: i had a mistake in the serial monitor so i did not get the output.
Sorry.

ballscrewbob

Thanks for coming back with the solution.

Bob.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up