|
Frequently Asked Questions
Questions
Answers
Q: mikroBasic 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, mikroBasic 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:
sub procedure interrupt
begin
' ISR code
sub end
Q: Do I need to save context at the beginning of the interrupt routine?
A: No, you don't. mikroBasic saves the following registers at the beginning of the interrupt: W, STATUS, FSR and PCLATH. All the same, mikroBasic restores the content of these registers upon return from the interrupt routine.
Q: What is the advantage of using local variables?
A: mikroBasic is capable of recycling RAM memory. If mikroBasic finds two procedures which do not call each other, it assigns the same RAM memory space for both procedures.
Q: How can I access individual bits of registers?
A: You can access individual bits of any variable of byte type. Use identifier followed by dot, and a pin: variable.PIN, where PIN is a constant value between 0 and 7. For example:
if PORTB.3 = 1 then ...
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 mikroBasic 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: mikroBasic 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: Debugger does not increment TMR0 during simulation.
A: mikroBasic 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 import.
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.
|