PDA

View Full Version : Program compiles and writes but can't run



jellis00
- 20th March 2009, 23:11
I am new to PICBasic Pro and the PICkit2 Starter Kit which I just purchased. I could get the PCBDemo to run via the PICkit2 with the PIC16F690 that came on the Demo board. However, when I tried run one of the sample programs that comes with PCIBASICPro Demo (SLEEP.bas), it compiles OK with MCS and I can import the resulting hex file into PICkit2 and target the device. It appears to write to the device OK, although the Verify finds an error mismatch in the Data memory, which I presume is not critical since the device has not executed the program yet or created any stored data.
However, when I try to run the program that was written to the device by clicking the box for /MCLR the program doesn't run. Here is the code I am trying to run which is very simple. Can anyone advise me what I may be doing wrong :in trying to run this program in PICkit2??
'SLEEP Command
'Slowly blink LED using low power mode delay

LED CON 16 'Identify LED pin

Loop:
TOGGLE LED
SLEEP 10
GOTO loop

Archangel
- 21st March 2009, 02:11
There is a little check box called ON listed below the text, VDD PIC Kit 2, it must be checked to power your demo board from the usb.

Archangel
- 21st March 2009, 02:13
There is a little check box called ON listed below the text, VDD PIC Kit 2, it must be checked to power your demo board from the usb. Here is a sample that works on that board.


;@MyConfig =
@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
@MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF
@ __config MyConfig

DEFINE OSC 4
PortA = 0
PortB = 0
PortC = 0
TRISA = 1
TRISB = 0
TRISC = 0
i var byte
ANSEL = 0
ANSELH = 0
CM1CON0 = 0
CM2CON0 = 0
main:

portc = 0
pause 500

for i = 1 to 15; step -1


portC = i
i=i << 1
pause 250
next i
sound portB.6, [120,2,124,2,123,2,121,2]
sound portC.6, [120,2,124,2,123,2,121,2]
goto main
end

jellis00
- 21st March 2009, 04:58
I already had the VDD PICK2 On box checked to power up the Demo board.

I tried to compile the code sample you provided that you say runs with this Demo board and I get a error 118...Overwriting previous address contents., and a large number of Errors #113..Symbol not previously defined.

Any other suggestions as to how to get the program to run??

Archangel
- 21st March 2009, 05:46
I already had the VDD PICK2 On box checked to power up the Demo board.

I tried to compile the code sample you provided that you say runs with this Demo board and I get a error 118...Overwriting previous address contents., and a large number of Errors #113..Symbol not previously defined.

Any other suggestions as to how to get the program to run??Ok, that is easy. In the PBP root directory there are files named for the PIC you are using, ending with the suffix .inc and in these files are "DEFAULT" config statements, like the one at the beginning of the code I listed. Open the 16F690.inc file located there and find the config line, The MPASM config line will say this
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF Add an ; semicolon like so
;__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF and that will solve the overwrite issue, you will for evermore have to include a config line into the code you write for this chip unless you change it back. OR you might try commenting it out in my code. Let's face it, the DEFAULT configs are there so noobies can get some code to run without knowing anything about config fuses, personally I think they serve to confuse people more than help, better I say, put this information in the manual and all the books on PICs.<br>By putting the configs in your code, it becomes easy to change oscillator, and MCLRE statements etc . . .<br><br>Now as for Symbol not previously defined, 2 main causes are inaccurate choices of symbols like BOR or MCLRE and others too, and The other MAIN reason is not having selected the correct PIC in Microcode Studio, and since I KNOW this code is correct, I would say that is the problem there. I notice it gets changed sometimes (which PIC is selected ) from the last I ran it. So you need to always check that first on compile failure with symbol error.

jellis00
- 21st March 2009, 06:20
OK, I understand about editing the include file.
However your instructions on selecting the right PIC in MicroCode Studio confuse me....I went thru all the menus in MSC and couldn't see where to do that. Please advise how I do that in MSC.

jellis00
- 21st March 2009, 06:29
Joe S., I commented out the line in the include file per your instructions and tried to compile again and still get all the 113 errors. ?????
Did I mention that I am using the PICBASIC PRO Demo compiler that came with the PICkit2 Starter Kit and not a production version of PICBASIC PRO Demo.....would that make a difference?

Archangel
- 21st March 2009, 07:37
Joe S., I commented out the line in the include file per your instructions and tried to compile again and still get all the 113 errors. ?????
Did I mention that I am using the PICBASIC PRO Demo compiler that came with the PICkit2 Starter Kit and not a production version of PICBASIC PRO Demo.....would that make a difference?Hmmm I don't know beans about the Demo version except you are limited as to how many lines of code it will run. Try removing the sound lines and any blank lines and try again, also try removing the code relating to unused ports, namely porta and b, or better yet try this, with the 16f690.inc file unaltered.

DEFINE OSC 4
LED_1 VAR BIT ' PORT FLAG BIT
LED_1 = 0 ' SET INITIAL VALUE
TRISC.0 = 0 ' Make PORTC.0 an output


Main:
IF LED_1 = 0 THEN
LED_1=1
ELSE
LED_1 = 0
ENDIF
PORTC.0 = LED_1




PAUSE 250 ' Delay for 1 second (compiler errors with this line - I guess the command isn't right!)
Goto Main ' Loop forever

jellis00
- 21st March 2009, 23:20
Joe S.,
Interestingly, when I copied this code int a Workspace project I created in MPLAB with PICkit2 set as programmer and PICBASIC Pro set as language, it compiles without any errors and will program into the PIC16F690 via the PICkit2 programming interface. It work as advertised this way.
However, if I copy the same code into MCS and try to compile it (with the PIC16F690.incl either normal or edited per you instructions) it creates all of the same 113 and 118 errors about not licking the symbols or overwriting....the original problem I observed.
I wanted to use the MCS/PICkit2 programming environment, but if I can't get it to compile the programs I will just have to use the MPLAB environment setup to operate with PICkit2. The reason I wanted to use MCS is because of its context help feature on PICBASIC syntax. I guess I can still write programs in MCS and then copy them into a Workspace on MPLAB for programming, but this is extra steps I wanted to avoid.

jellis00
- 21st March 2009, 23:24
Joe S.,
You didn't answer my one question in an earlier email regarding your instructions "The other MAIN reason is not having selected the correct PIC in Microcode Studio...." Since this may be causing the unrecognized symobl error, can you please tell me how to make the PIC selection in MCS? I looked thru MCS and couldn't see how to do that.

Archangel
- 21st March 2009, 23:27
Joe S.,
Interestingly, when I copied this code int a Workspace project I created in MPLAB with PICkit2 set as programmer and PICBASIC Pro set as language, it compiles without any errors and will program into the PIC16F690 via the PICkit2 programming interface. It work as advertised this way.
However, if I copy the same code into MCS and try to compile it (with the PIC16F690.incl either normal or edited per you instructions) it creates all of the same 113 and 118 errors about not licking the symbols or overwriting....the original problem I observed.
I wanted to use the MCS/PICkit2 programming environment, but if I can't get it to compile the programs I will just have to use the MPLAB environment setup to operate with PICkit2. The reason I wanted to use MCS is because of its context help feature on PICBASIC syntax. I guess I can still write programs in MCS and then copy them into a Workspace on MPLAB for programming, but this is extra steps I wanted to avoid. It is funny, the program never failed to compile and load from MCS through PICKit2. That said, it did say cancelled at the bottom, until I cut and pasted it into a new page in MCS and saved it as another name, it then compiled and said success. You and I might both need to reinstall MCS. The other code example I gave you . . . Did it work for you in MCS ?

mackrackit
- 22nd March 2009, 00:07
OK, I understand about editing the include file.
However your instructions on selecting the right PIC in MicroCode Studio confuse me....I went thru all the menus in MSC and couldn't see where to do that. Please advise how I do that in MSC.

Do you have the "compile and program" tool bar turned on?
If not go to view and select it from the tool bar option.
Then you should see a drop down list box with the supported chips.

jellis00
- 22nd March 2009, 00:31
The other code example I gave you . . . Did it work for you in MCS ?
Joe S., No, neither of the code sets would compile in MCS.

However, I think MACKTRAP led me to the solution. Once I did turn on the toolbar and set the device to PIC16F690 I was able to compile and program from MCS via PICkit2 for the code sets Joe S. provided as well as my other code samples I could not get to run.

Thanks so much to both of you for helping me resolve this problem.:o

mackrackit
- 22nd March 2009, 00:34
MACKTRAP
??????
:D
I have heard worse.

BigWumpus
- 22nd March 2009, 21:00
LED CON 16 'Identify LED pin


Which port should this be ???????

azmax100
- 23rd March 2009, 04:38
jellis00,

I do have the same problem before if I used MPASM to compile. Check your setting and don't use MPASM to compole.
I dont know whats the problem cause I'm still new but my program run smoothly without using MPASM. You should give a try.