Finding Mega0 Studio register and bit names?

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greetings, Freaks -

 

Been struggling with this for some time. It may be partially fueled by (relative) unfamiliarity with Windows compared to certain other operating systems. It certainly IS fueled by unfamiliarity with the Mega-0 include structure. So here is the situation:

 

Suppose that you do NOT have compilable code. Maybe it is just being created, or maybe there are some major errors. But, in any case, there is no list of dependancies and you can't click a register name or bit name to find its definition. Besides, bit names, especially, are inscrutably similar but not the same as the bit names in the spec sheet, and you don't have a valid  bit name to click on.

 

In this case of the compiler not being helpful, HOW do YOU find those valid register, bit, bit mask, and bit group names?

 

Thanks

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Mon. Sep 13, 2021 - 05:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

@Jim,

 

Create your AS7.0 project.   It will only have an empty main().   Build the project.

Then click on the Dependencies.

 

Now you can add your real project code and any modules, libraries, ...

 

However you can probably just hover on any known SFR or function.   Then right-click on "goto Implementation".

This should bring the necessary files into the Editor.

 

David.

Last Edited: Mon. Sep 13, 2021 - 05:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Start with a nice, safe, well-know symbol name like PORTA

Use the right-click "goto implementation", which should take you to the correct ioXXXX.h file, in spite of PACKS obfuscation.

For AVR, this is still a flat file with all the appropriate definitions, and is pretty easily searchable. (unlike the ARM files, which have a separate .h file for each "component.")

 

the first "goto implementation" should take you to:

#define PORTA                (*(PORT_t *) 0x0400) /* I/O Ports */

Then you can goto the implementation of the typedef for PORT_t:

    register8_t PIN3CTRL;  /* Pin 3 Control */
    register8_t PIN4CTRL;  /* Pin 4 Control */
    register8_t PIN5CTRL;  /* Pin 5 Control */
    register8_t PIN6CTRL;  /* Pin 6 Control */
    register8_t PIN7CTRL;  /* Pin 7 Control */
    register8_t reserved_2[8];
} PORT_t;

And then those names should be searchable to find the actual bit definitions.

/* PORT.PIN5CTRL  bit masks and bit positions */
/* PORT_ISC  is already defined. */
/* PORT_PULLUPEN  is already defined. */
/* PORT_INLVL  is already defined. */
/* PORT_INVEN  is already defined. */

....

#define PORT_ISC2_bm  (1<<2)  /* Input/Sense Configuration bit 2 mask. */
#define PORT_ISC2_bp  2  /* Input/Sense Configuration bit 2 position. */
#define PORT_PULLUPEN_bm  0x08  /* Pullup enable bit mask. */
#define PORT_PULLUPEN_bp  3  /* Pullup enable bit position. */
#define PORT_INLVL_bm  0x40  /* Input level select bit mask. */
#define PORT_INLVL_bp  6  /* Input level select bit position. */

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks!

 

Big help...

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:
(unlike the ARM files, which have a separate .h file for each "component.")

Yes,  Atmel SAMD header files are a complete nightmare.

 

However most OTHER manufacturers are not so bad.

 

David.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

My atdf2xlsx utility will convert an atdf file to excel, or emacs .org file, if that helps.

 

 

Last Edited: Tue. Sep 14, 2021 - 12:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can do a very simplistic version of that with just something like grep or findstr:

C:\Program Files (x86)\Atmel\Studio\7.0\packs\atmel\ATmega_DFP\1.6.364\atdf>grep "<register " ATmega328P.atdf
        <register caption="" name="EXTENDED" offset="0x02" size="1" initval="0xFF">
        <register caption="" name="HIGH" offset="0x01" size="1" initval="0xD9">
        <register caption="" name="LOW" offset="0x00" size="1" initval="0x62">
        <register caption="" name="LOCKBIT" offset="0x00" size="1" initval="0xFF">
        <register caption="USART I/O Data Register" name="UDR0" offset="0xC6" size="1" mask="0xFF" ocd-rw=""/>
        <register caption="USART Control and Status Register A" name="UCSR0A" offset="0xC0" size="1" ocd-rw="R">
        <register caption="USART Control and Status Register B" name="UCSR0B" offset="0xC1" size="1">
        <register caption="USART Control and Status Register C" name="UCSR0C" offset="0xC2" size="1">
        <register caption="USART Baud Rate Register Bytes" name="UBRR0" offset="0xC4" size="2" mask="0x0FFF"/>
        <register caption="TWI (Slave) Address Mask Register" name="TWAMR" offset="0xBD" size="1">
        <register caption="TWI Bit Rate register" name="TWBR" offset="0xB8" size="1" mask="0xFF"/>
        <register caption="TWI Control Register" name="TWCR" offset="0xBC" size="1" ocd-rw="R">
        <register caption="TWI Status Register" name="TWSR" offset="0xB9" size="1">
        <register caption="TWI Data register" name="TWDR" offset="0xBB" size="1" mask="0xFF"/>
        <register caption="TWI (Slave) Address register" name="TWAR" offset="0xBA" size="1">
        <register caption="Timer/Counter Interrupt Mask Register" name="TIMSK1" offset="0x6F" size="1">
        <register caption="Timer/Counter Interrupt Flag register" name="TIFR1" offset="0x36" size="1" ocd-rw="R">
        <register caption="Timer/Counter1 Control Register A" name="TCCR1A" offset="0x80" size="1">
        <register caption="Timer/Counter1 Control Register B" name="TCCR1B" offset="0x81" size="1">
        <register caption="Timer/Counter1 Control Register C" name="TCCR1C" offset="0x82" size="1" ocd-rw="">
        <register caption="Timer/Counter1  Bytes" name="TCNT1" offset="0x84" size="2" mask="0xFFFF"/>
        <register caption="Timer/Counter1 Output Compare Register  Bytes" name="OCR1A" offset="0x88" size="2" mask="0xFFFF"/>
        <register caption="Timer/Counter1 Output Compare Register  Bytes" name="OCR1B" offset="0x8A" size="2" mask="0xFFFF"/>
        <register caption="Timer/Counter1 Input Capture Register  Bytes" name="ICR1" offset="0x86" size="2" mask="0xFFFF"/>
        <register caption="General Timer/Counter Control Register" name="GTCCR" offset="0x43" size="1">
        <register caption="Timer/Counter Interrupt Mask register" name="TIMSK2" offset="0x70" size="1">
        <register caption="Timer/Counter Interrupt Flag Register" name="TIFR2" offset="0x37" size="1" ocd-rw="R">
        <register caption="Timer/Counter2 Control Register A" name="TCCR2A" offset="0xB0" size="1">
        <register caption="Timer/Counter2 Control Register B" name="TCCR2B" offset="0xB1" size="1">
        <register caption="Timer/Counter2" name="TCNT2" offset="0xB2" size="1" mask="0xFF"/>
        <register caption="Timer/Counter2 Output Compare Register B" name="OCR2B" offset="0xB4" size="1" mask="0xFF"/>
        <register caption="Timer/Counter2 Output Compare Register A" name="OCR2A" offset="0xB3" size="1" mask="0xFF"/>
        <register caption="Asynchronous Status Register" name="ASSR" offset="0xB6" size="1">
        <register caption="General Timer Counter Control register" name="GTCCR" offset="0x43" size="1">
        <register caption="The ADC multiplexer Selection Register" name="ADMUX" offset="0x7C" size="1">
        <register caption="ADC Data Register  Bytes" name="ADC" offset="0x78" size="2" mask="0xFFFF"/>
        <register caption="The ADC Control and Status register A" name="ADCSRA" offset="0x7A" size="1" ocd-rw="R">
        <register caption="The ADC Control and Status register B" name="ADCSRB" offset="0x7B" size="1">
        <register caption="Digital Input Disable Register" name="DIDR0" offset="0x7E" size="1">
        <register caption="Analog Comparator Control And Status Register" name="ACSR" offset="0x50" size="1" ocd-rw="R">
        <register caption="Digital Input Disable Register 1" name="DIDR1" offset="0x7F" size="1">
        <register caption="Port B Data Register" name="PORTB" offset="0x25" size="1" mask="0xFF"/>
        <register caption="Port B Data Direction Register" name="DDRB" offset="0x24" size="1" mask="0xFF"/>
        <register caption="Port B Input Pins" name="PINB" offset="0x23" size="1" mask="0xFF" ocd-rw="R"/>
        <register caption="Port C Data Register" name="PORTC" offset="0x28" size="1" mask="0x7F"/>
        <register caption="Port C Data Direction Register" name="DDRC" offset="0x27" size="1" mask="0x7F"/>
        <register caption="Port C Input Pins" name="PINC" offset="0x26" size="1" mask="0x7F" ocd-rw="R"/>
        <register caption="Port D Data Register" name="PORTD" offset="0x2B" size="1" mask="0xFF"/>
        <register caption="Port D Data Direction Register" name="DDRD" offset="0x2A" size="1" mask="0xFF"/>
        <register caption="Port D Input Pins" name="PIND" offset="0x29" size="1" mask="0xFF" ocd-rw="R"/>
        <register caption="Timer/Counter0 Output Compare Register" name="OCR0B" offset="0x48" size="1" mask="0xFF"/>
        <register caption="Timer/Counter0 Output Compare Register" name="OCR0A" offset="0x47" size="1" mask="0xFF"/>
        <register caption="Timer/Counter0" name="TCNT0" offset="0x46" size="1" mask="0xFF"/>
        <register caption="Timer/Counter Control Register B" name="TCCR0B" offset="0x45" size="1">
        <register caption="Timer/Counter  Control Register A" name="TCCR0A" offset="0x44" size="1">
        <register caption="Timer/Counter0 Interrupt Mask Register" name="TIMSK0" offset="0x6E" size="1">
        <register caption="Timer/Counter0 Interrupt Flag register" name="TIFR0" offset="0x35" size="1" ocd-rw="R">
        <register caption="General Timer/Counter Control Register" name="GTCCR" offset="0x43" size="1">
        <register caption="External Interrupt Control Register" name="EICRA" offset="0x69" size="1">
        <register caption="External Interrupt Mask Register" name="EIMSK" offset="0x3D" size="1">
        <register caption="External Interrupt Flag Register" name="EIFR" offset="0x3C" size="1" ocd-rw="R">
        <register caption="Pin Change Interrupt Control Register" name="PCICR" offset="0x68" size="1">
        <register caption="Pin Change Mask Register 2" name="PCMSK2" offset="0x6D" size="1">
        <register caption="Pin Change Mask Register 1" name="PCMSK1" offset="0x6C" size="1">
        <register caption="Pin Change Mask Register 0" name="PCMSK0" offset="0x6B" size="1">
        <register caption="Pin Change Interrupt Flag Register" name="PCIFR" offset="0x3B" size="1" ocd-rw="R">
        <register caption="SPI Data Register" name="SPDR" offset="0x4E" size="1" mask="0xFF" ocd-rw=""/>
        <register caption="SPI Status Register" name="SPSR" offset="0x4D" size="1" ocd-rw="R">
        <register caption="SPI Control Register" name="SPCR" offset="0x4C" size="1">
        <register caption="Watchdog Timer Control Register" name="WDTCSR" offset="0x60" size="1" ocd-rw="R">
        <register caption="Power Reduction Register" name="PRR" offset="0x64" size="1" ocd-rw="R">
        <register caption="Oscillator Calibration Value" name="OSCCAL" offset="0x66" size="1" mask="0xFF" ocd-rw="R">
        <register caption="Clock Prescale Register" name="CLKPR" offset="0x61" size="1" ocd-rw="R">
        <register caption="Status Register" name="SREG" offset="0x5F" size="1">
        <register caption="Stack Pointer " name="SP" offset="0x5D" size="2" mask="0x0FFF"/>
        <register caption="Store Program Memory Control and Status Register" name="SPMCSR" offset="0x57" size="1">
        <register caption="MCU Control Register" name="MCUCR" offset="0x55" size="1">
        <register caption="MCU Status Register" name="MCUSR" offset="0x54" size="1">
        <register caption="Sleep Mode Control Register" name="SMCR" offset="0x53" size="1">
        <register caption="General Purpose I/O Register 2" name="GPIOR2" offset="0x4B" size="1" mask="0xFF"/>
        <register caption="General Purpose I/O Register 1" name="GPIOR1" offset="0x4A" size="1" mask="0xFF"/>
        <register caption="General Purpose I/O Register 0" name="GPIOR0" offset="0x3E" size="1" mask="0xFF"/>
        <register caption="EEPROM Address Register  Bytes" name="EEAR" offset="0x41" size="2" mask="0x03FF"/>
        <register caption="EEPROM Data Register" name="EEDR" offset="0x40" size="1" mask="0xFF"/>
        <register caption="EEPROM Control Register" name="EECR" offset="0x3F" size="1">

C:\Program Files (x86)\Atmel\Studio\7.0\packs\atmel\ATmega_DFP\1.6.364\atdf>

The only "trick" in that being to know to look for "<register "

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Copy the mcu specific header (like iom4809.h) into your project folder so you always have a copy you can easily find/view whether you are in a 'helpful' ide/editor or not.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

curtvm -

 

Did that. My coding environment is BBEdit on a Mac. A local copy really simplifies things. I can actually have that iom4809.h open along with other project files and use grep-like find to get to desired definitions.

 

Thanks

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!