Hank Fletcher
New Member
I'm having trouble getting some code going to do what I'd expect it to do. Can I have some pointers? Here's my code:
I should remark this is my first attempt at writing directly in assembly, and compiling the code in MPLAB. Maybe I'm making a mistake there? Do I just have to export a hex file, and save my assembly, then import the hex file and then program the chip? That's what I've been doing, anyway, and every time I've programmed I haven't been warned of any errors.
I thought this code would set PortB.1 high, but testing with a voltmeter I don't see that happening (it just kind of sits like most of the other PortB pins around 0.05V when the power's on).
Everything after "Start of main program," is mine, but the code before that is part of the header I've copied from what GCBASIC compiles to initialize the chip. There's a variety of other stuff I cut that GCBASIC does by default to initialize the chip, too, so maybe there's something I'm missing about that, too?
Code:
;********************************************************************************
;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
;********************************************************************************
;********************************************************************************
;Start of the main program
STATUS equ 03h ;this assigns the word STATUS to the value of 03h,
;which is the address of the STATUS register.
TRISB equ 86h ;This assigns the word TRISB to the value of 86h,
;which is the address of the Tri-State register for PortB
PORTB equ 06h ;This assigns the word PORTB to 06h which is the
;address of Port B.
;********************************************************************************
bsf STATUS,5 ; select Bank 1
movlw 00h ; set the W register to 00h which
movwf TRISB ; sets all pins on PortB as outputs
bcf STATUS,5 ; select Bank 0
;Start of the main program
Start movlw b'10' ; put binary value in W register to
movwf PORTB ; set PortB.1 high an PortB.0 low
; movlw b'00' ; put binary value in W register to
; movwf PORTA ; set both PortB pins low again
goto Start ; rinse'n'repeat!
END
I thought this code would set PortB.1 high, but testing with a voltmeter I don't see that happening (it just kind of sits like most of the other PortB pins around 0.05V when the power's on).
Everything after "Start of main program," is mine, but the code before that is part of the header I've copied from what GCBASIC compiles to initialize the chip. There's a variety of other stuff I cut that GCBASIC does by default to initialize the chip, too, so maybe there's something I'm missing about that, too?
Last edited: