Counter external signal SAM4S

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

Hi everybody,

 

I am trying to count the number of pulses of a signal which is connected to PA4 using TC0. The uC is the sam4sd32c. This is the code that I am using

 

#include "sam.h"
#include "asf.h"

int main(void)
{
    
    SystemInit();
    

        sysclk_enable_peripheral_clock(ID_PIOA);
        ioport_set_pin_mode(PIO_PA4B_TCLK0, IOPORT_MODE_MUX_B);
        ioport_disable_pin(PIO_PA4B_TCLK0);
        sysclk_enable_peripheral_clock(ID_TC0); 
        tc_init(TC0, 0, TC_CMR_TCCLKS_XC1);
        tc_set_block_mode(TC0, TC_BMR_TC0XC0S_TCLK0);
        tc_start(TC0, 0);
        uint32_t count=0;
       

    while (1) 
    {
    count= tc_read_cv(TC0, 0);

    }
}

 

 

It has no errors but I doesn't work. Could you help me, please?

 

Thank you

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

I see this question an year later, but I assume you got it working? May I ask how?

I'm trying something similar but using TIAO1 (PD15 input).

Best regards,

David.