Simple delay for SAMD20

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

Hello,

 

I'm wondering if there is an easy way to insert a 1 clock cycle delay into my code execution.  The delay service code provided by ASF is only able to provide delays in microseconds, milliseconds and seconds (and not even accurately).  I'm running my clock at 48 MHz so I just want that extra ~21 ns before an I/O pin changes logic levels.  Changing the clock to a slower rate is not an option as I need the fastest possible change in other parts of my execution.

 

Thanks!

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

asm("nop");

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

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

Hey,

 

I don't know an easy way, but maybe you can add the TC module connect it to the same clock source count 1 cycle and continue.

I'm not sure 1 cycle will be possible, but you can look for TC example (tc_get_count_value(&tc_instance)).

 

Itay

 

 

 

 

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

did you try delay_cycles() ?