We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi friends,
I am using the AT91SAM7SE512,
i want to measure the external frequency(1KHz) using the Timer/counter. I have connected this frequncy to the PIO pin, The code is if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & Inputpin ) == 0 ) // count pulse {
if(s==1) { AT91C_BASE_TC0->TC_CCR = (AT91C_TC_CLKEN | AT91C_TC_SWTRG ) ; s=0; } } else {
AT91C_BASE_TC0->TC_CCR = (AT91C_TC_CPCDIS|AT91C_TC_CLKDIS ) ; s=1; value = AT91C_BASE_TC0->TC_CV; print(value); delay(50); } By using this code i can able to measure only 10Hz. But i want to measure up to 5KHz. can you please tell me the procedure to intialise the Timer/counter.
with regards, Murthy.R
www.danlhenry.com/.../keil_code.png
My code is
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & Inputpin ) == 0 ) // count pulse { if(s==1) { AT91C_BASE_TC0->TC_CCR = (AT91C_TC_CLKEN | AT91C_TC_SWTRG ) ; s=0; } } else { AT91C_BASE_TC0->TC_CCR = (AT91C_TC_CPCDIS|AT91C_TC_CLKDIS ) ; s=1; value = AT91C_BASE_TC0->TC_CV; print(value); delay(50); }
with regards Murthy.
You should first try to reformat your source code to improve the readability. As a result you make it easier to understand the code and to find errors for other and you.
en.wikipedia.org/.../Programming_style
Kind regards,
Rainer
hi friend , thanks for your suggestion, Here is the code
if((AT91F_PIO_GetInput(AT91C_BASE_PIOB)&Inputpin )==0) { if(s==1) { AT91C_BASE_TC0->TC_CCR=(AT91C_TC_CLKEN|AT91C_TC_SWTRG); s=0; } } else { AT91C_BASE_TC0->TC_CCR=(AT91C_TC_CPCDIS|AT91C_TC_CLKDIS ) ; s=1; value = AT91C_BASE_TC0->TC_CV; print(value); delay(50); }