''finding difficult and unable to get the output.''
Which part(s) are you finding difficult - doing the counting, or transmitting the count through the UART? Or both?
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Might help if you provide a more complete example. Or use the library code, if you are programming the device at the register level, you should be prepared to debug it at that level.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2011 at 14:17 Hi David, Try to configure PA15 in input floating: /* GPIOA clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); Before that check that PA15 is shared with JTAG so you will lose connection with your debugger (Check it because I am not sure). MCU Lüfter
Allow the counter to run 0000-FFFF and back. Don’t read out and reload as you may miss a pulse. When it’s time to report: temp = TMR2_CNT saveForSerialPort = (temp-savedT2) & 0xFFFF //mask or save as half word savedT2 = temp Time to report could be a timer ISR, a push button or a code event. If its either of the first two it’s best to do the above in an ISR. But don’t hang in that ISR until all your serial data is transmitted. Instead, save the count (in a FIFO if necessary) for your non-ISR code to convert into characters for RS-232. Verify the above by running T2 as a timer with an appropriate prescaler. This will divorce you from external events allowing for easier debug.
no matter what I tried I couldnot count ETR pulses - ( there is probably a bug in hardware ) try to count pulses at CH1 of the timer - it works in addition encoder mode 1 & 2 works like mode 3 ( another bug )