• AVR Freaks

Helpful ReplyProblem with system timer service

Author
usermanual
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/05/23 01:06:02
  • Location: 0
  • Status: offline
2017/05/25 06:00:05 (permalink)
0

Problem with system timer service

Hello.
I'm new to this forum. I am using MPLAB X IDE v3.51, Harmony Configurator and PIC32 Ethernet Starter Kit with PIC32MX795F512L. I wrote a program that implements the MODBUS protocol to polling the device at the set time interval. I have used the static timers driver so far, but due to the target application that is the web server I changed the timers used on one timer2 and I started to use the system timer service. With the callback function, I have different processes that start with different periods. The problem, however, starts when I enable the sending of a specific MODBUS frame using USART (by using callback function). The entire program always stops in the same place, during debuggingit it is in the program code of sys_tmr.c on line 896 "if (alarmCount <pTmrObj-> sysTickCount)", generating an exception with code = 7 ("Data bus error"). Does anyone have any idea what I should get started with because I have already finished all my ideas to fix this.
Thanks.
#1
BillP
Super Member
  • Total Posts : 436
  • Reward points : 0
  • Joined: 2014/09/28 07:53:35
  • Location: CA
  • Status: offline
Re: Problem with system timer service 2017/05/25 08:47:26 (permalink)
5 (1)
I believe you cannot mix static and dynamic timers.  If you are using the TCP/IP stack, you must use the dynamic timers.  So change the static one to a dynamic timer.  
#2
usermanual
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/05/23 01:06:02
  • Location: 0
  • Status: offline
Re: Problem with system timer service 2017/05/25 22:55:56 (permalink)
0
Dynamic timer is not so accurate as static, I have to use it to count 3.5 signs in MODBUS after sending frame, but as you said I'll try to use callback as one shoot (not period). Thanks.
#3
BillP
Super Member
  • Total Posts : 436
  • Reward points : 0
  • Joined: 2014/09/28 07:53:35
  • Location: CA
  • Status: offline
Re: Problem with system timer service 2017/05/26 07:48:22 (permalink)
0
How accurate do you need the timer to be? I have done tests on static and dynamic timers and can get both of them to be highly accurate at a 1 millisecond period.  In the Device Configuration tab/DEVCFG1 use PRIPLL, XT, and CSECME .  In the Drivers/Timer tab, use Dynamic, TMR Instance 0/Prescale=8 (not 256).  
 
Bill
#4
NKurzman
A Guy on the Net
  • Total Posts : 19031
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: Problem with system timer service 2017/05/26 09:37:53 (permalink)
3 (1)
You need to create a second instance of a dynamic timer. and set it to run at a higher rate than the Harmony timer.  Insure it Priority is higher.  OR just use one of the hardware timers directly.  Harmony is not doing anything you can't do better, for your specific application yourself.
 
BillP depending on the Buad rate 1 millisec may not be good for mod bus.  you need 1.5bits and 3.5 bit.
#5
usermanual
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/05/23 01:06:02
  • Location: 0
  • Status: offline
Re: Problem with system timer service 2017/05/29 01:30:08 (permalink)
0
I'm using 19200 bps, so 3.5 sign lasts ca. 1.82ms, I assume 2 ms. I changed as you said:
BillP
In the Device Configuration tab/DEVCFG1 use PRIPLL, XT, and CSECME .  In the Drivers/Timer tab, use Dynamic, TMR Instance 0/Prescale=8 (not 256).
but it still go to the exception. I tried already 
NKurzman
OR just use one of the hardware timers directly.
but the result was the same. I wonder if there is any influence dynamic timer driver with static usart driver, maybe after changing from static to dynamic timer I should also change static to dynamic usart? 
 
 
#6
usermanual
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/05/23 01:06:02
  • Location: 0
  • Status: offline
Re: Problem with system timer service 2017/05/29 06:07:55 (permalink) ☄ Helpfulby stephaneC 2017/06/12 02:31:58
5 (1)
Finally I changed code in procedure of preparing frame to send using timer directly (PLIB... functions) and the problem has gone. Maybe there was something wrong with pointers I used in the procedure - I'm not sure why this happened. Now I'm going to built in web_server. Thanks for answers. Regards.
#7
NKurzman
A Guy on the Net
  • Total Posts : 19031
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: Problem with system timer service 2017/05/29 08:09:49 (permalink)
0
The static and dynamic drive should not be interfering with each other.
#8
arpananand
Super Member
  • Total Posts : 498
  • Reward points : 0
  • Joined: 2009/11/18 04:35:42
  • Location: 0
  • Status: offline
Re: Problem with system timer service 2017/05/29 21:45:47 (permalink)
3 (1)
@usermanual
 
good to know that you are able to proceed now. if you still have some doubt on static vs dynamic usage of Harmony drivers, we can discuss.
#9
Jump to:
© 2020 APG vNext Commercial Version 4.5