PDA

View Full Version : Pic16f88 compiling. . not working



lerameur
- 29th October 2011, 18:04
Hello,

I am trying to figure how to use MPLAB in windows 7. Have installe MPLAB version 8.63 along with picbasic pro 2.60C. My following code compiles with no error:
'LCD testing program

OSCCON = %01110000 '8 Mhz
DEFINE OSC 8

'/////////////////////////
'// LCD configuration //
'/////////////////////////

DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTA ' Set LCD Register Select port
DEFINE LCD_RSBIT 2 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTA ' Set LCD Enable port
DEFINE LCD_EBIT 3 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
pause 1000


Mainloop:

lcdout $FE,1, " This is a test" '
lcdout $FE,$C0, "Next or Select" '
pause 200

GOTO Mainloop
End

Although it do not seems to work, nothing is showing on the LCD screen, just turns on.
Using Pic16F88. Tried different chip, rewired.. nothing. any ideas ?

Ken

Macgman2000
- 29th October 2011, 22:36
Sounds like you have 2 potential unknowns. From the sound of it, this is the first time you are using windows 7 and PBP. The second could be miss-wiring of the LCD. Try just getting an I/O port to turn on and off in a loop to make sure your MCU is actually running code. Put an LED or scope probe on portB.0 make sure your TRISB is set to digital output on bit 0.

Main:
portB.0 = 1
pause 1000
portB.0 = 0
pause 1000
goto main

If the above runs, then recheck your LCD.

Nick

lerameur
- 29th October 2011, 22:53
I used XP mode, to run 32 bit application. I compile it under dos and the program works fine including the LCD ..

ken

fratello
- 29th October 2011, 23:37
It's in your first row something like this :
@ DEVICE pic16F88, XT_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON ?

lerameur
- 30th October 2011, 04:02
here is the code:
'LCD testing program

@ DEVICE pic16F88, INTRC_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON
OSCCON = %01110000 '8 Mhz
DEFINE OSC 8

'/////////////////////////
'// LCD configuration //
'/////////////////////////

DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 0 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 1 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
pause 1000


Mainloop:

lcdout $FE,1, " This is a test" '
lcdout $FE,$C0, "Next or Select" '
pause 200

GOTO Mainloop
End


and here is the error message:
Executing: "C:\PBPDEMO\PBPW.EXE" -ampasmwin -k# -p16F88 "lcdtest.bas"
PICBASIC PRO(TM) Compiler 2.60C, (c) 1998, 2011 microEngineering Labs, Inc.
All Rights Reserved.

ERROR: Unable to execute mpasmwin.Warning[207] C:\PBPDEMO\LCDTEST.ASM 117 : Found label after column 1. (DEVICE)
Error[122] C:\PBPDEMO\LCDTEST.ASM 117 : Illegal opcode (pic16F88)
Halting build on first failure as requested.
BUILD FAILED: Sun Oct 30 00:00:24 2011


ken
but it does compile if I remove this line:
@ DEVICE pic16F88, INTRC_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON

but nothing happens on the LCD

lerameur
- 30th October 2011, 04:09
My MPlab is configures as following when I go into the language tools option.. in the executable:

C:\PBP\PBPMPLAB.BAT

K

fratello
- 30th October 2011, 06:57
Do you have this setting ?

lerameur
- 30th October 2011, 07:53
I dont have microcode studio, just MPLab and a plain text editor..

mackrackit
- 30th October 2011, 08:51
Micro Code Studio ships with PBP. It is on your install CD.

lerameur
- 30th October 2011, 14:49
Here is the configuration I have:
61016102

tenaja
- 30th October 2011, 15:16
Did you notice that it selected the assembler from your recycle bin?

Also, it has been several years since I worked with the 16f88, but iirc it has at least one of the peripherals enabled by default. You must go through each and every pin used with the lcd and make sure it is configured to be a regular i/o pin, and not configured as a peripheral pin.

lerameur
- 30th October 2011, 16:06
Yes I saw it refers to the recycling bin. although it does not find it automatically. and I do not know what to choose. The help file in the micro code studio is not very helpful in that regard.

k

lerameur
- 30th October 2011, 17:00
by removing this line:
@ DEVICE pic16F88, INTRC_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON
the code compiles but does not create the hex file !!

k

mackrackit
- 30th October 2011, 17:10
although it does not find it automatically. and I do not know what to choose.
MPASM should be C:\Program Files\Microchip\mpasm suite

or something like that.

lerameur
- 30th October 2011, 17:11
I installed version 4 of microCode studio, now it creates the Hex file.
Aleluia !!

K