Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic simulator IDE BASIC compiler error

dr_when

New Member
I get this nonsensical error when compiling using version 8.65. Have to keep hitting enter to get it to finish. No errors when it is finally done.


Internal compiler error!
Port related issue.
Please send the basic program you tried to compile to OshonSoft. Please use Help\Bug Report Interface menu command for that purpose...
 

Attachments

  • 1wire_display.bas
    2.5 KB · Views: 127
What PIC is this for? The defines for the REGisters (like SPI_CS_REG) usually point to things like PORTA, PORTB, PORTC, etc., not just a number.
That is, you are not defining the ports (registers) properly.
 
Why do you think this is a "nonsensical error"? Just because you don't understand it doesn't mean that it is nonsense.
 
This is a pic 12f675 that has no ports like PORTA, etc. Just GPIO. Also, this is a lower end part that needs OSCCAL. The error is nonsensical because it does eventually finish compiling (after hitting enter 8+ times) but offers no warnings or errors when done.
 
I tried the compile, and the assembly code seems to have compiled with "GPIO" used in the register declarations. Not sure if it runs however.
That all said, your code is incomplete as you do not define the frequency of the oscillator/crystal, so how can the compiler calculate the proper time intervals?
 
@Papabravo... do you have anything to offer other than criticism?
Yes, I do, even if you feel compelled to bite my head off.

Usually in a case like this you can get the compile to complete but you cannot have any confidence that the results will be useable. There may be errors in the object code outputs that you will not find until you burn a part and attempt to debug the result. You would do well get to the bottom of this before wasting your time and energy burning parts looking for the answer. The "f" in 12f675 means the code memory is flash so they can be reprogrammed multiple time.

If the error messages come out interactively, are you sure that you get a summary of the error messages when the compile completes. Can you verify this by asking for a listing and confirming that the compiler has produced such a summary?

For the record, GPIO is actually a "port", but it has a name that is particular to the part. GPIO is file register 05h and the corresponding TRISIO register is file register 85h. Additionally bits 6 & 7 of GPIO are unimplemented. The same goes for TRISIO.

Also, for the record, you have not offered any evidence that the error message is nonsense, nor have you confirmed that the result of compilation placed into a part works as you expect. Given those two realities, I would say that your assertion of the error message being nonsense, lacks credibility.
 
Last edited:
sagor1... "That all said, your code is incomplete as you do not define the frequency of the oscillator/crystal, so how can the compiler calculate the proper time intervals?"
Actually the Oshonsoft BASIC compiler and assembler let you set the proper configuration bits to use the 4mhz internal oscillator (that's where OSCCAL comes in... to adjust that internal oscillator.) That is all covered in the 12f675 data sheet. When I initially tried using "GPIO" instead of "PORT" I got an error and thus used 5 instead knowing that GPIO is 0x05.

Other than that, a compiler message of
"Internal compiler error! Port related issue." did not really give me much of a clue. The error was actually the result of missing statements:

#define SPI_SDO_REG = GPIO
#define SPI_SDO_BIT = 4

Still don't understand why that would cause the message I saw, but Vladimir usually gets back to me pretty quick and he will typically have a good answer.
 
sagor1 ...from the data sheet

INTERNAL 4 MHz OSCILLATOR
When calibrated, the internal oscillator provides a fixed 4 MHz (nominal) system clock. See Electrical Specifications. Section 12.0. for information on variation over voltage and temperature.
Two options are available for this Oscillator mode which allow GP4 to be used as a general purpose I/O or to output Fosc/4.

Calibrating the Internal Oscillator
A calibration instruction is programmed into the last location of program memory. This instruction is a RETIN where the literal is the calibration value. The literal is placed in the OSCCAL register to set the calibration of the internal oscillator. Example 9-1 demonstrates how to calibrate the internal oscillator. For best operation, decouple (with capacitance) Voo and Vss as dose to the device as possible.
 
dr_when ! I have known Sagor for quite some years and good ol Papa for even longer.

Please don't think they are "Critic's" that just troll and smirk.
When someone enters a forum, we have no idea on your skill level,

I know the pic12f675 very well and the OSCAL register can lose its value and needs resetting. Once you "reprogram" it is lost and will need resetting using pickit2 if you have one.

As for 1 wire communication . Vlad bitbangs' the SPI you will be far better off writing your own and not specifying the reg's he uses as he will set things up you do not need.

I have a 1 wire bit bang example in the forums( badly kept ) code repository here.
Its in C and ASM for the 8051 micro but you may see something you need.

When I return home, I will simulate you code and see whats wrong.
 
sagor1 ...from the data sheet

INTERNAL 4 MHz OSCILLATOR
When calibrated, the internal oscillator provides a fixed 4 MHz (nominal) system clock. See Electrical Specifications. Section 12.0. for information on variation over voltage and temperature.
Two options are available for this Oscillator mode which allow GP4 to be used as a general purpose I/O or to output Fosc/4.

Calibrating the Internal Oscillator
A calibration instruction is programmed into the last location of program memory. This instruction is a RETIN where the literal is the calibration value. The literal is placed in the OSCCAL register to set the calibration of the internal oscillator. Example 9-1 demonstrates how to calibrate the internal oscillator. For best operation, decouple (with capacitance) Voo and Vss as dose to the device as possible.
For bit banging, Vladimir uses the crystal frequency to determine the timing loops using software code. The compiler directive stating frequency is what is used to determine those loops. Now, it might default to 4Mhz, I don’t know, but always best to declare it in the code.
Setting configuration bits does not tell the compiler what frequency you are running the clock at, it only sets the PIC.
PS: the ASM code for osccal should be commented out when used in the SIM, else the jump to 3FF causes unpredictable results unless you manually put a correct op code in that location before starting the SIM.
 
Last edited:
Sagor..

you said:
Now, it might default to 4Mhz, I don’t know, but always best to declare it in the code.
You can set the clock frequency in the IDE and that becomes the "default" so you dont need it
 
You are right Ian. However, if loading one program then another, the IDE frequency setting stays the same, whatever the previous value was. By declaring it in the code, it sets the IDE clock frequency to what the code says. This prevents "forgetting to set it" in the IDE if compiling different code at different times with different crystals or internal frequency selection. I'll stick to declaring it in the code, it is more fail-safe. I've always done it in the code, never tried setting it in the IDE because my IDE always showed the right frequency. Others can do what ever...
 
On another note, does anyone know of a way to easily comment out multiple lines of code in the Basic compiler? I usually end up just cutting out code that I temporarily want to block and paste it in another editor. I am used to C with */ multiple comments
blah blah blah */
 
If you have lost the value of the OSCCAL record, years ago I made a little program to recover it.

I leave the link to the video in which you can see how it finds the ideal value. You have to wait about 30 seconds to see the result.

If there is interest I can create a new thread where I can post it.

Retrieve the value of osccal.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top