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
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).
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.
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.