dsPIC33EP512GP806 Timer issues - Only TMR1 working

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

dsPIC33EP512GP806 Timer issues - Only TMR1 working

Post 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
Attachments
TMR1 and TMR2 enabled
TMR1 and TMR2 enabled
TMR.jpg (11.89 KiB) Viewed 3527 times

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Post 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.

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Post 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
Attachments
TIMER_REGISTERS.jpg
TIMER1 THROUGH TIMER9 REGISTER MAP
(140.86 KiB) Downloaded 477 times

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Post 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

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: dsPIC33EP512GP806 Timer issues - Only TMR1 working

Post 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

Post Reply