Gemma M0 and Trinket M0 with Timer interrupt

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ymlim11
 
Posts: 22
Joined: Fri Jun 22, 2018 8:41 am

Gemma M0 and Trinket M0 with Timer interrupt

Post by ymlim11 »

Hi, I tried to use timer interrupt with timer 0 and timer 1 on Gemma M0 and Trinket M0. But I tried to do the initialization of enabling TCC as the instruction of ATSAMD21E18 datasheet. But it keep output error like "'CTRLA' was not declared in this scope" when I tried both codes as below.

Code: Select all

CTRLA.PRESCALER = 0x0;
or

Code: Select all

CTRLA |= _BV(ENABLE);
;

How I going to fix it?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Gemma M0 and Trinket M0 with Timer interrupt

Post by adafruit_support_mike »

It's easier to use the attachInterrupt() function.

If you want to work with the registers directly, your best bet is to dig through the board support package and look at the file Winterrupts.c

https://github.com/adafruit/ArduinoCore ... terrupts.c

User avatar
ymlim11
 
Posts: 22
Joined: Fri Jun 22, 2018 8:41 am

Re: Gemma M0 and Trinket M0 with Timer interrupt

Post by ymlim11 »

Yeah, I know. But attachInterrupt() need an input pin to trigger the Interrupt function and all GPIO pin is used for other purpose. And it won't accept delay function because it doesn't has a timer.

I use one of your successful projects

Code: Select all

https://learn.adafruit.com/trinket-gemma-blinky-eyes?view=all#code
as a reference. if we can enable the timer, we can use a timer to trigger ISR() function.

But i follow the instruction from 31.6.2.2 of ATSAMD21E18 datasheet, it can't declared the address name of the register from processor.

i wise to fix the problem, so i can use timer to trigger instead of using hardware

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Gemma M0 and Trinket M0 with Timer interrupt

Post by adafruit_support_mike »

That project uses the original Trinket and Gemma, which have 8-bit ATtiny85 microcontrollers. The Trinket M0 and Gemma M0 use a 32-bit SAMD21E, which is a completely different architecture.

Register-based code and code related to the interrupts will be completely different.

User avatar
ymlim11
 
Posts: 22
Joined: Fri Jun 22, 2018 8:41 am

Re: Gemma M0 and Trinket M0 with Timer interrupt

Post by ymlim11 »

I know. That's why I had mention ATSAMD21E18 datasheet. But unlike 8-bit ATtiny85 microcontrollers, it given an error like "not declared in this scope " whenever the register-based code from ATSAMD21E18 I used.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Gemma M0 and Trinket M0 with Timer interrupt

Post by adafruit_support_mike »

And the variables aren't declared in scope because the SAMD21E doesn't have those registers. Different architecture, different interrupt system, different macros for the registers.

User avatar
sokuno
 
Posts: 2
Joined: Fri Aug 17, 2018 11:54 am

Re: Gemma M0 and Trinket M0 with Timer interrupt

Post by sokuno »

Did anybody figure out the proper register-based variables? I'm having the same problem with the Trinket M0. I tried looking through some documents for the Trinket M0's IC (https://www.microchip.com/wwwproducts/en/ATSAMD21E18) and Winterrupts.c, but I didn't get very far... I will keep trying but in the meantime did anybody else come up with something?

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”