|
Frequently Asked Questions
Questions
Answers
Q: mikroPascal compiler generated code without errors, but PIC is not responding when the program is loaded.
A1: Using in-line assembly may corrupt memory banking process. When user writes his assembly, mikroPascal leaves it intact. Therefore, in case of in-line assembly, user has to take care of the memory banking issues.
A2: Some PICs differ in initialization demands. For example, if using 16F877A, user should disable internal comparator in order to use PORTA as digital I/O. In case that user selected 16F877 as a target controller, this initialization is not necessary. Therefore, user should pay attention to init states of similar PICs.
Q: How do I write interrupt handler for my PIC?
A: Simply declare a procedure named 'interrupt' and place your code there:
procedure interrupt;
begin
//ISR code
end;
Q: Do I need to save context at the beginning of the interrupt routine?
A: No, you don't. mikroPascal saves the following registers at the beginning of the interrupt: W, STATUS, FSR and PCLATH. All the same, mikroPascal restores the content of these registers upon return from the interrupt routine.
Q: What is the advantage of using local variables?
A: mikroPascal is capable of recycling RAM memory. If mikroPascal finds two procedures which do not call each other, it assigns the same RAM memory space for both procedures.
Q: I wrote a program for 16Fxxxx PIC. What do I need to change in order to make it work with P18 PICs?
A: Compiler will do most of the job for you. Generally, the real power of mikroPascal lies in the fact that very little needs be changed during transition to another PIC.
Q: Debugger is not entering interrupt service routine, though there are all conditions to do so.
A: mikroPascal debugger is not capable of determining whether a ISR condition is satisfied. However, you can easily switch to the ISR by clicking the ISR button (shortcut key F12) on the watch window, or going to menu Run -> Generate Interrupt. In this way, a real interrupt case is simulated.
Q: Why can't I use the condition while(1) to create an infinite loop?
A: The constant true has value 255 in mikroPascal. Statement while(num) compares num to 255, and if equal, returns true. As 255 does not equal 1, statement while(1) cannot be used to create an infinite loop. Solution would be to use the statement while(true) or while(255).
Q: Debugger does not increment TMR0 during simulation.
A: mikroPascal Debugger is not capable of determining which special function registers are timers. Therefore, it cannot update such SFRs. If you want to simulate changes in TMR0, you should modify it in the code manually.
Q: I would like to share my source code with others. How do I do that?
A: You are free to send the source code to whoever you want. Everything final user needs to do is to include your code in his project by means of keyword
uses.
If you do not want to disclose the source code, you can send your compiled library (file extension .mcl) - user will be able to use your library as if he had the source code. Although the compiler is able to determine which routines are implemented in the library, it is a common practice to provide routine prototypes in a separate txt file.
|