Page 1 of 1

dsPIC33EP512GP806 Timer issues - Only TMR1 working

Posted: Wed May 08, 2013 8:49 am
by ronaldlijs
Hi guys,

I have an issue with Flowcode dsPIC (5.5.2.1), seems as the main timer interrupt TMR1 works well, I've got it counting at one speed rate (about 1 per second).

However when I add a second timer TMR2/3/4/5 or any other timer available for this dsPIC, it just doesn't work at all. I'm talking about the program running on hardware I am not simulating anything here. I always run the program directly on the dsPIC on hardware.

Even if I remove TMR1 and leave TMR2 on its own counting, it does not count on hardware.

Could this be a bug? How can I troubleshoot this issue?

Thanks,
Ronald

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Posted: Wed May 08, 2013 10:45 am
by ronaldlijs
From the Data Sheet for this dsPIC

"The Timer1 module is a 16-bit timer, which can serve as the time counter for the real-time clock, or operate as a free-running interval timer/counter."

"The Timer2/3, Timer4/5, Timer6/7 and Timer8/9 modules are 32-bit timers, which can also be configured as four independent 16-bit timers with selectable operating modes. "

Coudl this be related? The other timers need to be actually initialized as 16-bit ones, otherwise they'll run as 32bit ones?

I'm trying to check the C code generated by Flowcode now, but I'm afraid I am not C proficient...

Ronald

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Posted: Wed May 08, 2013 10:56 am
by Benj
Hello Ronald,

All the timers should be configured to 16-bit mode. Can you confirm that all the timers are set to use the internal clock source rather then the external.

If your still having issues then let me know and I will investigate the C code for you.

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Posted: Wed May 08, 2013 11:18 am
by ronaldlijs
OK, I have found something weird, some code is commented out of C:\Program Files (x86)\Flowcode(dsPIC)\v5\Tools\C_tools\support\dsPIC33E\inc\p33EP512GP806.inc.

Example:

;----- T3CON Bits -----------------------------------------------------
;.equiv TCS, 0x0001
;.equiv TGATE, 0x0006
;.equiv TSIDL, 0x000D
;.equiv TON, 0x000F

;.equiv TCKPS0, 0x0004
;.equiv TCKPS1, 0x0005

I have uncommented entries for T3CON / T5CON / T7CON / T9CON and now these timers all work fine!!

But still the issue remains with TMR2/4/6/8 as they have a 32bit flag and of course seems as Flowcode is unable to set these timers correctly... Although 4 extra timers is not bad, my code might need more :-)

Ben and guys, can anyone have a look at this as I'd like to sue the other timers too :-) More importantly you'll need to fix the include file p33EP512GP806.inc. Pic below shows Timer register map from the Data Sheet... Not there is a T32 bit that needs to be set for T2/4/6/8

Hope this helps, cheers!!
Ronald

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Posted: Wed May 08, 2013 11:26 am
by ronaldlijs
Thanks Ben,

Yes I had them as internal clock, but the program would just freeze on hardware, that's when I found the commented code :-)

Cheers!
R

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Posted: Wed May 08, 2013 11:30 am
by ronaldlijs
OK, all timers are working now, I've uncommented all of them and used internal clock for all my timers (double checked), so all fine!

You can close this one and you should also review include files for other CPUs as I have seen the same on other files...

I'm running Flowcode 5.5.2.1

Hope this helps and thanks!
Ronald