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
Direct write to PCL
- slavisa.zlatanovic
- mikroElektronika team
- Posts: 1321
- Joined: 07 Apr 2009 09:39
Re: Direct write to PCL
Hi!
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>.
...
Regarding the possible part: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?
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
Slavisa
-
- Posts: 417
- Joined: 10 Jan 2009 22:03
Re: Direct write to PCL
But you are not going to advise it though..
Jim
Jim