(SOLVED) Help needed understanding parameters please. Arduino Nano every PWM registry entries,

Good day everyone.

I am asking for help here so please be nice as I am not at all program savvy but am trying to understand the timer registries on the nano every. I've downloaded and printed out the entire 551 pages of the Atmega 4809 and I am having some trouble, the code below I have copied from

this page

after lines like

PORTMUX.TCBROUTEA |= PORTMUX_TCB1_bm;

and

  TCB1.CTRLB = 0 << TCB_ASYNC_bp      /* Asynchronous Enable: disabled */
               | 1 << TCB_CCMPEN_bp   /* Pin Output Enable: enabled */
               | 0 << TCB_CCMPINIT_bp /* Pin Initial State: disabled */
               | TCB_CNTMODE_PWM8_gc; /* 8-bit PWM */

Right at the end there is a "_bm" or "_bp" or "_gc" before the semi colon in small letters, I have gone through the entire timer A and B chapters but do not find references to what these small letters mean. could someone please explain them to me or point me to page specifics int the 551 page manual where I might find the references to these lower case letters?

Thank you in advance!
Regards.

pinMode(3, OUTPUT);   //Port F, Pin 5 = Arduino ~D3       
 
 
  /* set the alternate pin mux */
  PORTMUX.TCBROUTEA |= PORTMUX_TCB1_bm;
  
  
  TCB1.CCMPL = 255; /* PWM Period*/

  TCB1.CCMPH = 128;   /* PWM Compare*/

  TCB1.CTRLB = 0 << TCB_ASYNC_bp      /* Asynchronous Enable: disabled */
               | 1 << TCB_CCMPEN_bp   /* Pin Output Enable: enabled */
               | 0 << TCB_CCMPINIT_bp /* Pin Initial State: disabled */
               | TCB_CNTMODE_PWM8_gc; /* 8-bit PWM */

  // TCB1.DBGCTRL = 0 << TCB_DBGRUN_bp; /* Debug Run: disabled */

  // TCB1.EVCTRL = 0 << TCB_CAPTEI_bp /* Event Input Enable: disabled */
  //     | 0 << TCB_EDGE_bp /* Event Edge: disabled */
  //     | 0 << TCB_FILTER_bp; /* Input Capture Noise Cancellation Filter: disabled */

  // TCB1.INTCTRL = 0 << TCB_CAPT_bp; /* Setting: disabled */

  TCB1.CTRLA = TCB_CLKSEL_CLKDIV1_gc  /* CLK_PER (No Prescaling) */
               | 1 << TCB_ENABLE_bp   /* Enable: enabled */
               | 0 << TCB_RUNSTDBY_bp /* Run Standby: disabled */
               | 0 << TCB_SYNCUPD_bp; /* Synchronize Update: disabled */

               
  TCB1.CTRLA |= TCB_ENABLE_bm;

According to this document, the abbreviations stand for:

  • _bm: Bit Masks.
  • _bp: Bit Positions.
  • _gc: Group Configurations.

By the way, this does nothing:

Hi @jfjlaros Thank you.

Is it a must to enter these in as I have also seen entries without those at the end.

Thanks in advance!
Regards.

They are just constants, so it depends on how they were named by the author of the core. Perhaps they both exist, I do not know.

You could try the following:

Serial.println(TCB_CAPT_bp);
Serial.println(TCB_CAPT);

The use of the _gc suffix seems to be a convention in the datasheet:

There is no mention of the _bm and _bp suffixes.

Thank you kindly @jfjlaros

@jfjlaros
When compiling Serial.println(TCB_CAPT_bp); the serial monitor returns a 0 but when trying to compile Serial.println(TCB_CAPT); The compiler returns an error saying,
'TCB_CAPT' was not declared in this scope Interesting.

Again, Thank you for taking the time to explain this.

1 Like

Much more information on the register naming conventions and the use of Bit Masks, Bit Group Masks and Group Configuration Masks can be found here.

http://ww1.microchip.com/downloads/en/DeviceDoc/AVR1000b-Getting-Started-Writing-C-Code-for-AVR-DS90003262A.pdf

@cattledog
Thank you very much will go and read up on that, Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.