Possible issue w/ new InitPitOSSem() and InitPitOSFlag funcs

Discussion to talk about software related topics only.
Post Reply
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Possible issue w/ new InitPitOSSem() and InitPitOSFlag funcs

Post by Ridgeglider »

I've run across what I think is an issue with the new 54415 functions to send semaphores and flags from PIT1 and Pit2 timer IRQs. Both functions work fine on either Pit1 or 2 by themselves. However, if you setup one PIT, say for use with SEMx, then set up the other available timer for use withe either a 2nd semaphore, say SEMy, or a flag, then the specified interval for the original timer will be affected. The attached code demos the issue.

As currently commented, the atached code sets up a semaphore for use with PIT1 running 10x /sec. The while loop in UserMain waits for 1 sec using OSTimeDly. Then another (nested) while loop calls OSPendNoWait on the semaphore and prints out whether the semaphore was rec'd or not. As expected, after waiting for 1 sec, when the nested loop runs, it pulls out 10 or 11 semaphores every sec. I presume the additional, 11th semaphore is recd due to the 1 tick resolution of OSTimeDly. So far so good, all is running as expected.

However there is additional code (now commented) that can set up PIT2, either for use in conjunction with another semaphore, or a flag: the Pit2_Sem, or Pit2_Flag objects. If you uncomment either line 116, or 117 to start PIT2 w/ either of these objects, then you clobber PIT1 so that it no longer produces 10 semaphores per second.

I looked into pitr_sem.cpp and thought I saw the problem in the Init functions where Psem or pflag are loaded, and in the INTERRUPTS where pSem or pFlag is tested, and if non-zero, the semaphore or flag is posted. It seems to me that if there are two timers, there need to be pointers to 2 semaphores, and 2 flags. I tried modifying the code to init, and subsequently test and jump to something like pSem[timer] or pFlag[timer] but, although it ran, it did not solve the issue.

File atached.
Attachments
main.cpp
(5.1 KiB) Downloaded 310 times
Post Reply