I have recently bought an Arduino Nano RP2040 connect and I want to see if I can replace the normal Arduino Nano with the new board to improve the performance of my datalogging applications
One issue I am having however is finding a list of available MACROs or equivalents online for using the RP2040 connect. For example, if I'm using the normal Nano, which is based on the Atmega328p, I know I can use the following registers:
ADMUX - Choose ADC channel and ref voltage, set final 4 bits to 1000 for temp sensor
ADCSRA - Can be used to enable/disable ADC by setting ADEN bit high/low
PRR - Power reduction register, disable clock to certain peripherals to save power
SMCR - Choose the mode the Atmega328p uses when the device goes to sleep
MCUCR - Can be used to enable/disable BOD before going to power-down sleep mode
which are all defined as MACROs within the Arduino IDE. So for example, I can measure the internal temperature of the Atmega328p's temperature sensor using:
ADMUX = bit (REFS0) | bit (REFS1) | 0x08; //use internal temperature sensor
bitSet (ADCSRA, ADSC); //start a conversion
while (bit_is_set(ADCSRA, ADSC)); //wait for it to finish
uint16_t temp_10bit = ADC; //read 10-bit value from ADC register
So, if I wanted to have the same level of control on the RP2040 connect, and achieve all that is detailed above, will I just have to skim through the RP2040 datasheet?
I'm willing to put the work in if that's the case, it would just be nice to know if there is a link or page somewhere where examples are available for new users.
If you want to write low level code you need to read the datasheet and the source code.
New users are not supposed to write code the way you are writing it. Your code is not portable and that is why you need to rewrite your code now.
The Arduino RP2040 connect is not just a faster Atmega328. It is designed for communication. That is inherently asynchronous and unpredictable. Try that stuff. It is less control and you will need to rely on libraries a lot more, but it is still fun. You can use Strings and do not need to count bytes ...
you should become familiar with the OS (RTOS?) running on that chip and the data sheets of the on-board controllers and peripheral chips. Or use the well known analogRead() function to obtain 12 bit ADC values.
Did you already download the board data sheet and read sections "16.1 Getting started - IDE" and following?
I have tried downloading the datasheet from the Arduino store and the RP2040 datasheet but I could not find the section your refer to, could you provide me a link for the datasheet you used?