Modify Arduino Nano to use mega328PB
Quote from 14mmcv on October 17, 2024, 4:59 pmHow can I modify the Arduino Nano to use the atmega328PB chip - as it is used on some cheap clones to enable simulation of the additional features - like the additional HW-Timers 3 & 4 ....
Or is it easier to build a new Block my own and use a mega328PB ?
How can I modify the Arduino Nano to use the atmega328PB chip - as it is used on some cheap clones to enable simulation of the additional features - like the additional HW-Timers 3 & 4 ....
Or is it easier to build a new Block my own and use a mega328PB ?
Quote from arcachofo on October 18, 2024, 4:26 amHi.
You can modify or create a new one if copy and rename the files at simulide/data/arduino/Nano
Open the subcircuit in Simulide: simulide/data/arduino/Nano/Nano.sim1
There you edit the circuit:
- Change the chip.
- Right-click in the package and click in "Select Exposed Components", then click in the atmega328PB chip (it will get yellow).
- Save the circuit.If you create a new one you should add it to simulide/data/arduinos.xml
Hi.
You can modify or create a new one if copy and rename the files at simulide/data/arduino/Nano
Open the subcircuit in Simulide: simulide/data/arduino/Nano/Nano.sim1
There you edit the circuit:
- Change the chip.
- Right-click in the package and click in "Select Exposed Components", then click in the atmega328PB chip (it will get yellow).
- Save the circuit.
If you create a new one you should add it to simulide/data/arduinos.xml
Quote from 14mmcv on October 27, 2024, 12:11 pmThank you for that advice.
It did work for Timer 3 & 4 - which are new in the PB.
But I have a problem with the ADC.
I use the ADC with a ISR for ADC Ready.
In that ISR I loop through all 8 analog Inputs - this works and with a breakpoint in the ADC ISR I can see the ADMUX and ADCSRA are correctly set - but what-ever I connect to the analog Inputs - no results in the ADCL & ADCH register - always 0
Here the code for the ADC ISR - the ISR is started with the same settings in the setup() function and A0 to A7 are defined as INPUT/*
Interrupt Service Routine to handle ADC-Ready interrupt
stores 16 samples sequential for all analog input channels
*/
ISR(ADC_vect){
digitalWrite(10, HIGH);
ADC_Values[index>>3 & 0x0F][index & 0x07] = ADCL + (ADCH << 8);
index++;
index &= 0x7F;
ADMUX = 0x40 + (index & 0x07);
ADCSRA = 0xC0 + 0x08 + ADC_CLK; // Enable and Start ADC with Interrupt Enabled and ADC-Prescaler = 7
digitalWrite(10, LOW);
if(index == 0) ADC_Flag = 1;
}This works perfect on real HW - but not in this simulator
Thank you for that advice.
It did work for Timer 3 & 4 - which are new in the PB.
But I have a problem with the ADC.
I use the ADC with a ISR for ADC Ready.
In that ISR I loop through all 8 analog Inputs - this works and with a breakpoint in the ADC ISR I can see the ADMUX and ADCSRA are correctly set - but what-ever I connect to the analog Inputs - no results in the ADCL & ADCH register - always 0
Here the code for the ADC ISR - the ISR is started with the same settings in the setup() function and A0 to A7 are defined as INPUT
/*
Interrupt Service Routine to handle ADC-Ready interrupt
stores 16 samples sequential for all analog input channels
*/
ISR(ADC_vect){
digitalWrite(10, HIGH);
ADC_Values[index>>3 & 0x0F][index & 0x07] = ADCL + (ADCH << 8);
index++;
index &= 0x7F;
ADMUX = 0x40 + (index & 0x07);
ADCSRA = 0xC0 + 0x08 + ADC_CLK; // Enable and Start ADC with Interrupt Enabled and ADC-Prescaler = 7
digitalWrite(10, LOW);
if(index == 0) ADC_Flag = 1;
}
This works perfect on real HW - but not in this simulator
Quote from 14mmcv on October 27, 2024, 12:41 pmThanks for the fast reply - I found it in the meanwhile - I had no C on AREF - now it seem to work
Thanks for the fast reply - I found it in the meanwhile - I had no C on AREF - now it seem to work
Quote from 14mmcv on October 27, 2024, 4:03 pmIt does not work correctly - all samples are full scale - all 10 bits set, whatever is connected at A0 to A7
Also tested on bare 328PB
It does not work correctly - all samples are full scale - all 10 bits set, whatever is connected at A0 to A7
Also tested on bare 328PB
Quote from arcachofo on October 27, 2024, 6:30 pmADC for Atmega328PB is working for me.
Can you share your circuit and firmware to have a look?
ADC for Atmega328PB is working for me.
Can you share your circuit and firmware to have a look?
Quote from 14mmcv on October 29, 2024, 7:42 amI've setup my configuration again from scratch - now it is working perfectly.
Congratulation and thanks for that great tool.Any intention to add more cores like ARM (RPi Pico & Pico2), RISC-V and ESP?
I've setup my configuration again from scratch - now it is working perfectly.
Congratulation and thanks for that great tool.
Any intention to add more cores like ARM (RPi Pico & Pico2), RISC-V and ESP?
Quote from arcachofo on October 29, 2024, 10:45 amGlad to know you got it working.
Any intention to add more cores like ARM (RPi Pico & Pico2), RISC-V and ESP?
I would love to do that, but by now we don't have the resources to do it.
Implementing each one of those devices can take hundreds if not thousands of hours of work.There is some work in progress to support 32 bit CPUs, but just this will take some time.
Glad to know you got it working.
Any intention to add more cores like ARM (RPi Pico & Pico2), RISC-V and ESP?
I would love to do that, but by now we don't have the resources to do it.
Implementing each one of those devices can take hundreds if not thousands of hours of work.
There is some work in progress to support 32 bit CPUs, but just this will take some time.