Working on the edge of SAMD21G18 - DMA and register counting to 255 at full CPU frequency

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

Hello,

 

I'm starting up a project where i will have to use a SAMD21 and a external counter for example 74LS590D( does not have high enough bandwidth, but it is just a good example)
I wanna try replacing the 74LS590D 8 bit counter with the SAMD21G18. As it got the DMA function AND I'm awaiting 25 of them.
I did some research earlier and if i did single instruction loop where i count to 255 using assembly INC function I would in theory be able to to count at full CPU frequency aka 48MHz.
I don't need to have any interrupts running while counting so I can do a while loop until reaching the count of 255.
But I am really unsure how fast the DMA is and if I can get it to work just as fast as the counter. I don't have any eval board for it right now so i can't test out anything yet.
The only detail I've found is that with PORT.PINCFG.DRVSTR enabled it can drive 20pF capacitance at 15ns rise and 15ns fall so if i reduce the trace capacitence to less than 20puff i should be able to push it. 1/15ns = 66MHz and that it runs off AHB clock which is max 48MHz so I would say that limits the whole concept to CPU clock / 2 unless there is a way to have the AHB clock running out of phase with the CPU clock but that surely doesn't sound healthy.

 

TL;DR. Need a 8 bit parallel clock counter using DMA running 48MHz with SAMD21G18.

Last Edited: Sun. Oct 3, 2021 - 06:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

if i did single instruction loop where i count to 255 using assembly INC function

How do you expect to loop AND count in a single instruction?  (and presumably test for an end condition as well?)

 

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

I've never really looked into assembly before but after i posted this thread i started learning assembly. I did not know it had to execute a jmp for each loop cycle.
I've managed to just bitbang at 16MHz on a Arduino Uno so i think it should be possible to do some magic on the samd21 
As i can't find the instruction set for the SAMD i can't figure out some tricks. 
Problem is to bitbang on the Arduino uno i have to overwrite the whole PORTD as that is the only way of clearing and setting new bits at 1 CPU cycle and now that the SAMD21 is 32 bit register i don't like clearing out the whole 32 bit register

 

I did figure out that you could use 

PORT->Group[0].OUTTOGGLE.reg[0] 
to do it but I bet it spends more CPU cycles than you expect 

Last Edited: Tue. Oct 5, 2021 - 07:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some discussion on pin wiggle speed here: https://forums.adafruit.com/view...

 

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

Decee1 wrote:
i can't find the instruction set for the SAMD

It's not specific to SAMD - what you need is the instruction set for the Cortex-M0+

 

Decee1 wrote:
to bitbang on the Arduino uno i have to overwrite the whole PORTD as that is the only way of clearing and setting new bits

Really?

 

Surely is has SET, CLEAR, and TOGGLE bit registers ... ?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...