Porting RTOS for microC

Post your requests and ideas on the future development of mikroC.
Post Reply
Author
Message
testerplus
Posts: 32
Joined: 27 Sep 2008 22:39
Location: Russia, SPb
Contact:

Porting RTOS for microC

#1 Post by testerplus » 27 Sep 2008 22:47

Hello, everybody!

I trying to port russian RTOS OSA (http://wiki.pic24.ru/doku.php/en/osa/ref/intro or http://picosa.narod.ru) under mikroC compiler for PIC16-controllers.

There is one general problem: I can't get current program counter value. Library function setjmp() does not work correctly: it just reads register pair PCLATH:PCL, but PCLATH can contain any value, but not high byte of program counter. Thus this function return incoorect value of program counter.

I tried to get PC using inline assembler. There is an operator "$" (by linker "$" is substituted by current ROM address), but using "$" is possible only with call and goto instuctions. I need to use it with movlw, but compiller tells me: "Message No. 0: $: const not found"

Does anybody know any other way to get current program counter?

Thank you!

Victor Timofeev.

P.S. RTOS OSA is freeware and all source code included. I know that many people interested in RTOS under mikroC and asked about it, but there is no any. So I think all you will be interested in free RTOS for microC compiller. Soon all documentation will be translated in english.
Last edited by testerplus on 21 Dec 2008 16:52, edited 1 time in total.

idakota
Posts: 334
Joined: 27 Sep 2006 08:07
Location: Pretoria/South Africa
Contact:

#2 Post by idakota » 28 Sep 2008 08:49

What kind of PIC is this?

The PIC24s store their program counters in the PCH:PCL pair

testerplus
Posts: 32
Joined: 27 Sep 2008 22:39
Location: Russia, SPb
Contact:

#3 Post by testerplus » 28 Sep 2008 13:46

PIC16.

In this series of PICs the PCLATH is only used for modifying program counter but not for reading.

There is no problem with PIC24, dsPIC or PIC18. Only with PIC16, PIC10, PIC12.

Dr Jeff
Posts: 13
Joined: 09 Dec 2007 21:39
Location: Lyme Regis, ENGLAND
Contact:

#4 Post by Dr Jeff » 21 Dec 2008 16:30

Hi Testerpluss,

did you ever find a way to do this?

I too spotted this problem - for PIC16 setjmp can not work (I guess it wprks for the 'examples' as these ensure PCLH will be zero as they are simple demos !!!)

I am not using setjmp but writing a workround macro to overcome stack limitations where RAM is available.

All I need is to be able to access the current PC value from the linker e.g. MOVLW #$ or similar (even LBL: MOVLW #LBL would do!!!)

Please help us ME team

Jeff

testerplus
Posts: 32
Joined: 27 Sep 2008 22:39
Location: Russia, SPb
Contact:

#5 Post by testerplus » 21 Dec 2008 16:52

Dr Jeff wrote:Hi Testerpluss,

did you ever find a way to do this?
No, I didn't. I understood that there is no way to get current PC value for PIC10, 12, 16. I have only one idea: to write an utilite, that will modify HEX-file. But in this case it will be unable to debug program.
Dr Jeff wrote: All I need is to be able to access the current PC value from the linker e.g. MOVLW #$ or similar (even LBL: MOVLW #LBL would do!!!)
Both methods: "movlw #$" and "LBL: movlw #LBL") will not work (compiler exits with an error)

Testerplus.

kangus
Posts: 28
Joined: 17 May 2006 21:02

PIC18 MikroC version

#6 Post by kangus » 04 Feb 2009 18:18

What did you end up having to do to get a MikroC version to compile?
Thanks

testerplus
Posts: 32
Joined: 27 Sep 2008 22:39
Location: Russia, SPb
Contact:

Re: PIC18 MikroC version

#7 Post by testerplus » 04 Feb 2009 18:30

kangus wrote:What did you end up having to do to get a MikroC version to compile?
Thanks
I need some free time.
Besides, there are too little people who interested in RTOS for mikroC.

testerplus
Posts: 32
Joined: 27 Sep 2008 22:39
Location: Russia, SPb
Contact:

Re: PIC18 MikroC version

#8 Post by testerplus » 05 Mar 2009 17:37

I tried to test new mikroC PRO (http://www.mikroe.com/forum/viewtopic.php?t=18620). I am glad that in-line assembler construction:

Code: Select all

movlw $
now works for PIC16!

Later I'll check simulator with PUSH, POP, RETURN ect instructions for PIC18 (they did not work in 8.2).
Last edited by testerplus on 05 Mar 2009 17:49, edited 1 time in total.

testerplus
Posts: 32
Joined: 27 Sep 2008 22:39
Location: Russia, SPb
Contact:

Re: PIC18 MikroC version

#9 Post by testerplus » 05 Mar 2009 17:48

testerplus wrote:Later I'll check simulator with PUSH, POP, RETURN ect instructions for PIC18 (they did not work in 8.2).
Just checked: all works correctly! :)

Post Reply

Return to “mikroC Wish List”