SAMD51 Timer Interrupt

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

Hi,

 

I'm a beginner on SAMD51 MCU and Atmel Start. I have been trying to write my own DALI master implementation for a while. For this project, I need a 1us timer interrupt. I have been fighting with the Atmel Start for a week but I have started to get mad configuring it.

 

I able to get 1ms timer task using the HAL Timer drivers but when I try to change the "Length of one timer tick in uS" to 1uS, I get 51uS in the task. I think this is the lowest level I can achieve now because even if I try to increase it a little bit, I still get 51uS. I am using the 120MHz clock as the source of the timer (TC1).

 

I attached my atmel_start_config file. Can anyone please guide me on this? I don't know why it is so hard to do configure a simple timer interrupt. HAL drivers should make developers life easier but it makes things more complicated with these tasks.

 

 

Attachment(s): 

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

Why do you need a 1us interrupt for DALI Master. This seems awfully fast. Just the isr servicing overhead will consume a significant amount of cpu performance.
For DALI you would normally use the timer compare feature for sending and the capture feature for receiving.

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

Hi Kartman,

 

Unfortunately, I couldn't run the ATSAMD51 timer capture module properly for a week. Configuring it over Atmel Start is very complicated it made me very mad figure it out. I got an example on SAMD21 from a support case but it didn't work for me either when I port it to SAMD51. 

 

You're right about using timer capture/compare features since it would be better to make the HW do the job for us. But the deadline is getting closer and I got very tired trying to figure out the Atmel Start. So I just wanted to run a 1uS timer and write my own bit-banging software. All I can have is a 50uS timer now and it is very hard to fit the timing regulations of the backward frame using 50uS timer...

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

Personally I wouldn't even consider Atmel Start. Maybe just have it generate enough code to configure the clocks etc, but I'd directly access the timer hardware - it really isn't that difficult. Besides, doesn't Arduino have a core library for it? till you'd need to access the timers directly, but at least you escape Start.

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

Kartman wrote:

Personally I wouldn't even consider Atmel Start. Maybe just have it generate enough code to configure the clocks etc, but I'd directly access the timer hardware - it really isn't that difficult. Besides, doesn't Arduino have a core library for it? till you'd need to access the timers directly, but at least you escape Start.

 

There are Arduino Dali libraries but I don't know how to use them with ATSAMD51. Besides most of the Arduino codes are built with delays and I don't want that. I really started to feel stupid because I couldn't set up the timer compare module properly for couple of weeks. This is my first time with SAMD MCUs, I had used XMEGAs before and it was easier to directly write to the registers and there were many examples. 

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

There’s circuit python for the d51. This might allow you to interactively configure the timers. Once you’ve determined the correctconfiguation, then you can resume with your C code.
The Arduino suggestion was to not even touch Start, but use the Arduino framework to get you going.

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

Thanks Kartman, I didn't use circuit python before but I will search it!