Well, mine is missing the config line. I need to add one. It's assuming you're setting it with MPLAB.I'll give that a try. I'm sure with Bill's code it's something basic I'm missing in terms of writing, compiling, programming the PIC.
LIST p=16F88
include "P16F88.inc"
__config _CONFIG1, 0x3f2a
No.1) I open up MPLAB.
2) I select File> New.
3) This opens an "Untitled" window, which I notice is very bare, as in no code or even PC numbers in the margin when I type stuff in. That's new to me, because they're always there when you compile from GCBASIC.
4) I copy and paste in futz's code, but the text is all black, as in no colour-coding that I usually see in a compiled GCBASIC program. Also, the "program," "release from reset," etc icons are not present.
That's where I'm at. Can you get me to point B?
Yay, I have colours now!kchriste said:That's because you haven't saved the file yet. Save it as blinky.asm and then you'll get your code colours.
D'oh! I should have realized that. This has been wearing on me a bit, I think!To get these, you need to select your programmer. Click "Programmer/Select Programmer" and select the ICD2, etc.
Okay, I'll give that a try. I'm gonna go with kchriste's suggestions first, and if that doesn't work I'll try doing through the project wizard.futz said:Well, mine is missing the config line. I need to add one. It's assuming you're setting it with MPLAB.
I'm still getting nothing.No PORTA.7 pin 16
Many A ports are A/D or have comparators that have to be disabled, A7 is a digital I/O pin by default.
LIST p=16F88
include "P16F88.inc"
__config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON
ERRORLEVEL 0, -302
cblock 0x20
d1,d2,d3
endc
org 0x0000
init
banksel CMCON ;bank 1
movlw 0x72 ;8MHz internal osc
movwf OSCCON
movlw 0x07 ;turn comparators off
movwf CMCON
clrf ANSEL ;all pins digital
movlw 0x00 ;all pins outputs
movwf TRISA
movwf TRISB
banksel PORTA ;select bank 0
main bsf PORTA,1
call delay
bcf PORTA,1
call delay
goto main
delay movlw 0x15
movwf d1
movlw 0x74
movwf d2
movlw 0x02
movwf d3
delay_0 decfsz d1,f
goto dd2
decfsz d2,f
dd2 goto dd3
decfsz d3,f
dd3 goto delay_0
return
end
#include <system.h>
#include <stdio.h>
#pragma CLOCK_FREQ 8000000
#pragma DATA _CONFIG, _WDT_OFF & _INTRC_IO & _LVP_OFF & _MCLR_ON
void main(void)
{
osccon=0x72;
cmcon=0x07;
ansel=0;
trisa=0;
while(1){
porta.1=1;
delay_ms(500);
porta.1=0;
delay_ms(500);
}
}
#chip 16F88, 8
#config OSC = INTRC_IO, MCLR_ON
'Set the pin directions
dir PORTA.1 out 'check the PIC pins for these ports!
'Main routine
Start:
SET PORTA.1 ON
wait 1 sec
SET PORTA.1 OFF
wait 1 sec
goto Start
;Program compiled by Great Cow BASIC (0.9 10/2/2007)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;********************************************************************************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=16F88, r=DEC
#include <P16F88.inc>
__CONFIG _CONFIG1, _INTRC_IO & _MCLR_ON & _WDT_OFF & _LVP_OFF
;********************************************************************************
;Set aside memory locations for variables
DELAYTEMP equ 32
DELAYTEMP2 equ 33
DELAYTEMP4 equ 34
SysTemp1 equ 35
SysTemp2 equ 36
SysWaitTempMS equ 37
SysWaitTempS equ 38
;********************************************************************************
;Jump to initialisation code when PIC is reset
ORG 0
call INITSYS
goto SystemInitialise
;********************************************************************************
;Interrupt vector
ORG 4
retfie
;********************************************************************************
;Various initialisation routines, automatically called by GCBASIC
SystemInitialise
;********************************************************************************
;Start of the main program
banksel TRISA
bcf TRISA,1
START
banksel PORTA
bsf PORTA,1
movlw 1
movwf SysWaitTempS
call Delay_S
bcf PORTA,1
movlw 1
movwf SysWaitTempS
call Delay_S
goto START
BASPROGRAMEND
sleep
goto $
;********************************************************************************
;Subroutines included in program
;********************************************************************************
DELAY_MS
DMS_START
movlw 10
movwf DELAYTEMP2
DMS_OUTER
movlw 66
movwf DELAYTEMP
DMS_INNER
decfsz DELAYTEMP, F
goto DMS_INNER
decfsz DELAYTEMP2, F
goto DMS_OUTER
decfsz SysWaitTempMS, F
goto DMS_START
return
;********************************************************************************
Delay_S
DS_START
movlw 10
movwf DELAYTEMP4
DS_OUTER
movlw 100
movwf SysWaitTempMS
call Delay_MS
decfsz DELAYTEMP4, F
goto DS_OUTER
decfsz SysWaitTempS, F
goto DS_START
return
;********************************************************************************
INITSYS
movlw 112
movwf SysTemp1
banksel OSCCON
movf OSCCON,W
banksel SysTemp1
iorwf SysTemp1,W
banksel OSCCON
movwf OSCCON
banksel PORTA
clrf PORTA
clrf PORTB
movlw 7
banksel CMCON
movwf CMCON
banksel ADCON0
bcf ADCON0,ADON
banksel ADCON1
bcf ADCON1,ADFM
clrf ANSEL
banksel STATUS
return
;********************************************************************************
END
I used GCBASIC for the above, but when I started this thread (and what I'm trying to learn here) I was just writing the assembly code into MPLAB. The programmer is an ICD2 clone (called ICD2.5) that I bought from a Vancouver distributor. I'd link to it, but I don't think they're selling it anymore. It's worked great up to now, and I'm humble enough to admit that I'm more inclined to think it's (my) human error at this point.It would help if we knew the programmer / software you're using. Some do not import the config fuses properly.
I'm ashamed to say I don't know how to do that. I know that's embarrassing!PS try using your ICD2 as a debugger. You can see exactly what it's doing that way.
Can I view that in MPLAB, and if so, how?Post your .hex file that doesn't work.
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F88 "billink.asm" /l"billink.lst" /e"billink.err"
Warning[205] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 1 : Found directive in column 1. (list)
Error[105] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 2 : Cannot open file (Include File "(p16f88.inc)" not found)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 3 : Symbol not previously defined (_CONFIG1)
Error[126] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 3 : Argument out of range (not a valid config register address)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 5 : Symbol not previously defined (STATUS)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 5 : Symbol not previously defined (RP0)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 7 : Symbol not previously defined (OPTION_REG)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 9 : Symbol not previously defined (TRISA)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 10 : Symbol not previously defined (STATUS)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 10 : Symbol not previously defined (RP0)
Error[113] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 12 : Symbol not previously defined (PORTA)
Error[173] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 15 : Source file path exceeds 62 characters (C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM)
Halting build on first failure as requested.
BUILD FAILED: Sat Jun 07 23:23:10 2008
list p=16f88
include (p16f88.inc)
__CONFIG _CONFIG1, 0x2F34
org 0
bsf STATUS, RP0
movlw b'00001110'
movwf OPTION_REG
movlw b'00111111'
movwf TRISA
bcf STATUS, RP0
movlw b'10000000'
xorwf PORTA, f
sleep
end
Huh, those really are supposed to be greater and less than signs around the include! Fixed the "list" error and deleted the superfluous "config," but I'm still getting this:I guess I did the brackets for the include wrong, or something?
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F88 "billink.asm" /l"billink.lst" /e"billink.err"
Message[302] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 7 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 9 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[173] C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM 15 : Source file path exceeds 62 characters (C:\PROGRAM FILES\GCBASIC\NOT GCBASIC FILES (ASSEMBLY CODED)\BILLINK.ASM)
Halting build on first failure as requested.
BUILD FAILED: Sat Jun 07 23:33:53 2008
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?