SAM4s, ASF, and Quadrature Decoder

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

Posts: 1
Joined: Tue Jan 14, 2014 5:37 am

SAM4s, ASF, and Quadrature Decoder

Wed Jan 15, 2014 4:58 am

Hello All,

I am new to SAM4S and ASF. I am hoping that somebody can help me to implement a quadrature decoder on my SAM4S Xplained Pro board. So far I have confirmed that TC's work in general, I have been able to create interrupts, interrupt handling routines, and have confirmed that I can use TIOA and TIOB as inputs to a TC. But I am struggling to find the correct ASF functions to implement the correct registers in the correct order for a quad decoder. Here is a code snippet that I have been playing with.

isr_counter and CV_Q are static uint32's. isr_counter increments so I know that the ISR is called. CV_Q never changes though.

Code: Select all

// Configuration function for the quadrature decoder. 
static void tc_config_quad(void) { 
   tc_set_block_mode(TC0, TC_BMR_QDEN | TC_BMR_POSEN);    
   tc_start(TC0,0);   // is this required? what about CLKEN in CCR? 

// Interrupt service routine 
void TC_Handler(void) 
   CV_Q = TC0->TC_CHANNEL[0].TC_CV; 
I should mention that I have tried to implement the code shown at the following url, and I have the same issue... code compiles and loads, but the counter never increments.


I would be grateful for any advice, tutorials, examples. Do I need to call the ASF functions in some order (e.g. tc_sync_trigger() before tc_start() )? I have found examples in the API documentation for XMEGA, but not SAM ... am I missing something?

Posts: 1
Joined: Wed May 21, 2014 11:13 am

Re: SAM4s, ASF, and Quadrature Decoder

Wed May 21, 2014 11:15 am

Take a look at ... _encoders/
It is for the Xmega but it might still help you
Posts: 2
Joined: Wed May 27, 2015 12:26 pm

Re: SAM4s, ASF, and Quadrature Decoder

Sat May 30, 2015 2:06 pm

could you solve the issue?
I have faced the same issue with sam4e

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest