Direct write to PCL

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Direct write to PCL

#1 Post by JimKueneman » 22 Jan 2011 16:33

Hi,

Back with the 8 bit PICs I use to create state machines by creating a jump table where I would add the state index to the PC to jump directly to the line of code which was a function call to the task to do for that state. I eliminated a lot of if...then... blocks by doing this. I currently have a large state machine that is very time sensitive. Currently I am using a case statement for the "jump table". the case statement ends up with a lot of comparisons and goto calls. By the time I get near the end of my state machine the case statement takes longer than some of the tasks!

Questions are:
1) Can you/is it advisable to write to the PCL in a dsPIC?
2) Is it possible/advisable to do a PCL write with an asm block in mikroPascal?

Thanks,
Jim

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: Direct write to PCL

#2 Post by slavisa.zlatanovic » 24 Jan 2011 11:21

Hi!
1) Can you/is it advisable to write to the PCL in a dsPIC?
2) Is it possible/advisable to do a PCL write with an asm block in mikroPascal?
Regarding the possible part:
Yes, it is possible.

See the asm Declaration in the Help file:

Accessing variables
Depending on the place of declaration, accessing a variable can be done in several ways :

Accessing global variable :
1. If declared as static (visible only in the file where it was declared) : <source_file_name>_<variable_name>.
2. If declared as a non-static global (visible throughout the whole project) : _<variable_name>.
3. If accessing registers (declared through register, rx or sfr specifiers, visible throughout the whole project) : <variable_name>.
Accessing local variable : <routine_name>_<variable_name>.
Accessing routine parameter : FARG_<routine_name>_<variable_name>.
...
Best regards
Slavisa

JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Re: Direct write to PCL

#3 Post by JimKueneman » 24 Jan 2011 13:58

But you are not going to advise it though.. :wink:

Jim

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”