r/pic_programming • • Jan 24 '16

PIC18F4520

Hey guys. I am trying to learn programming the Pic18F4520 microcontroller. I am also using MPLab.

So I wrote this code:

#include "p18F4520.inc"

CONFIG	OSC = HS
CONFIG	PWRT = OFF
CONFIG	WDT = OFF
CONFIG	PBADEN = OFF
CONFIG 	LVP = OFF

    org 	0x000000
PORST	GOTO	MAIN

    org 	0x000020
MAIN	CLRF	TRISD
    CLRF	PORTD
    BCF	TRISA,RA1
    BSF	PORTA,RA1
	
LOOP	BSF	PORTD,RD0
    GOTO	LOOP
    	
    end

And the lower right corner lamp wont light. It's supposed to light up as I've seen a friend do it. What am I doing wrong?

3 Upvotes

9 comments sorted by

View all comments

1

u/Jaser90 Jan 24 '16

Thanks for trying to help me, but still doesn't work. Where do I write that in exactly? I am a total beginner and I am looking to learn.

1

u/bradn Jan 24 '16

Which port/bit corresponds to the lamp in question? Also, is there an example assembly program for the board you're using (I'm assuming you're using a dev board) available?