ATmega328P works ATmega48 not (yet)

I made a sketch for the ATmega328P which works flawlessly but not on an ATmega48V

Interrupts on timer1 nRf24L01+ NF24 library Analog read

I wanted to put that on a board with an ATmega48V which I found on ebay.

The Analog read and interrupts work on the ATmega48V but the nRf24L01+ library is not working

For uploading the software I added the Pololu ATmega48 board info and modified the FCPU to 8000000, verified the fuse settings and measured the interrupt pulse width. The interrupt speed is correct.

This is the board info I use to upload the sketch using an AVRISP programmer

orangutan_48.name=Pololu Baby Orangutan B-48 w/ ATmega48 orangutan_48.upload.tool= orangutan_48.upload.maximum_size=4096 orangutan_48.upload.maximum_data_size=512 orangutan_48.build.mcu=atmega48 orangutan_48.build.f_cpu=8000000L orangutan_48.build.board=AVR_ORANGUTAN orangutan_48.build.core=arduino:arduino orangutan_48.build.variant=arduino:standard

According the datasheet all register names are equal between ATmega328P and ATmega48V

Any ideas in what direction I should look for a solution?

Please explain exactly what you mean by "not working".

Does the 48V have the same amount of SRAM as the 328P? Is it enough for the library? 512 bytes vs 2K. What does the compiler report?

The program is very small, 3.2k and fits in the ATmega48. Compiling and uploading through the AVRISPII works on both ATmega328P and ATmega48V.

The program sends out a pulse between 1 and 2 ms depending on the analogRead of the potmeter, I checked the pulse width with the pololu slow scope and that matches the calculation. 8000000/8/1000=1000 so a potmeter value between 0 and 1023 works great.

The only part that is not working is the nRf24L01+ when installed on the ATmega48V, if I install the sketch on an ATmega328P it sends the potmeter value out and I can receive it on another Arduino.

I found this board on ebay, search: ATmega48 nRf24L01+ I used BlinkLed to find the pin number for CS(9) and CSN(10).

erikjanssen: The program is very small, 3.2k and fits in the ATmega48.

So it doesn't use much flash. We know that. But what about SRAM?

I added some serial print functions in order to track error status and the program is a little bigger now:

Sketch uses 3,878 bytes (94%) of program storage space. Maximum is 4,096 bytes. Global variables use 141 bytes (27%) of dynamic memory, leaving 371 bytes for local variables. Maximum is 512 bytes.

With the serial I could verify that the send operation works only if the receiver is online, neat feature of the nRf24L01+. Now I know this I can take that away again.

Without the serial information:

Sketch uses 2,658 bytes (64%) of program storage space. Maximum is 4,096 bytes. Global variables use 38 bytes (7%) of dynamic memory, leaving 474 bytes for local variables. Maximum is 512 bytes.

The ATmega328P runs on 16Mhz and the ATmega48V on 8Mhz, The receiver is also a ATmega328P on 16mHz.

I found another example that worked well on the ATmega328 but refuses to function on the ATmega48 with the internal resonator.

For now I stop trying, it is costing too much time. Case closed.