Register and ISR(ADC_vect) - where to find the documentation or code information

Hi,

I'm following these tutorials about level up my Arduino code :

Very good they are! But I currently don't know where this guy find this informations :

In regard of the ATmega32U4 documentation, Where did he found the correct registered named with Arduino library ?

I know that's the same named as the documentation but if the Arduino developper want to named it differently he can do it. I'm not able to find an Arduino documentation about it.
Also I'm currently not able to find this line of code inside the Arduino library ("for the moment")

Where did he found the ISR(ADC_vect) function and the variable ADC_vect ?
Not found in the documentation and the library as well.

Why I'm asking it ?

For audio purpose,
I currently need a higher ADC sampling. But I need to change my Arduino card from the Micro to the Arduino Nano 33 BLE Sense. (ATmega32U4 to nRF52840 microcontroller)

I'm currently not able to retrieve the named of each registers from the document as it could be with the Micro card documentation. The IDE come up with a lot of errors. The registers named in the document are not the same with Arduino code...

Where I can find registers and functions named in the Arduino documentation or the Arduino library ?

Thank you,

Where did he found the ISR(ADC_vect) function and the variable ADC_vect ?

It’s part of the avr-libc startup code that comes with gcc.
Most of them should be documented in the avr-libc manual, but I don’t know how up-to-date that is WRT newer chips.

You can find it in …/hardware/tools/avr/avr/include/avr/iom32u4.h
The actual include chain is something like:

  • The compile of your sketch does “#include <Arduino.h>” from the Arduino Core, automatically.
  • Arduino.h does “#include <avr/io.h>”
  • io.h includes one of the 300-odd avr/io*.h files depending the the chip type specified on the compile line.

Thank you for your reply. I understand how it works now!

Unfortunately,
the Arduino Nano 33 BLE Sense is based on the nRF52840 microcontroller.
If someone can help me to find this information ? :slight_smile:

the Arduino Nano 33 BLE Sense is based on the nRF52840 microcontroller.

Ah… that’s different.

  • First of all, the ARM chips don’t use the ISR() syntax for defining an interrupt handler. ISRs are just like regular functions, and all you have to do is create a function with the correct name.
  • The “correct name” is usually of the form peripheralname_Handler() Don’t forget that it’s a “C” name rather than a C++ name, so you’ll need to either put it in a .c file, or wrap it in “extern “C””:

[/list]

extern "C" {
  void SAADC_IRQHandler_v(void)
  {
    digitalWrite(13, 1);
  }
}

[/li]

  • These are usually defined as weak symbols in the ARM vector table in the Startup.S or Startup.C file.
  • I can’t find a startup file for the nrf52840. There’s a startup_NRF52840.o mentioned in the .map file produced by a board, but apparently it’s part of “libmbed.a”, which we only see in binary form. There might be documentation or more info as part of the Nordic support for mBed.
  • You CAN dump the handler names from any built Arduino sketch binary, using the “nm” tool. Something like
[b]arm-none-eabi-nm /tmp/Arduino1.8.10Build/test_pwm.ino.elf | grep Handler
[/b]

(Once you’ve figured out where the tools are, and where the binaries go.)

  • The nrf52840 Arduino core is built on top of mBed. mBed is built on top of the Nordic SDK. There could be additional layers of interrupt handling stuff to deal with. I’m pretty sure at least one of those relocates the vector table to RAM, and the Nordic core has “soft devices” which may prevent use of hardware interrupts entirely (but maybe only for proprietary stuff like the radio.)

A “how can I use an interrupt-driven ADC on an Arduino Nano 33 BLE Sense?” would probably be a better question…