PIC18 first time programing - help!!

Thread Starter

Shreder001

Joined Mar 7, 2009
22
Hey guys this is my first time programing a PIC18 and a have a few questions. I am doing it in assembly language. My first goal is to turn an LED on but i cant quite seem to do that yet. Heres my program:

#include <p18F2431.inc>
CONFIG = _CONFIG1H, 0x06

CONFIG = _CONFIG2L, 0x0E
CONFIG = _CONFIG2H, 0x1E

CONFIG = _CONFIG3L, 0x3C
CONFIG = _CONFIG3H, 0x9D

org 0000

BANKSEL TRISA
CLRF TRISA
BANKSEL PORTA
BSF PORTA,0


end

Im not sure how to configure it. Every time i try to build it, i get this error message:
Missing argument(s) (configuration byte setting is missing)

What do I do? Thanks!!!
 

AlexR

Joined Jan 16, 2008
732
Your syntax for setting the configuration bits is wrong.

You can set individual function using the CONFIG command, eg
Rich (BB code):
  CONFIG OSC = HSPLL
  CONFIG WDTEN = ON
;and so on.
Take a look at the P18F2431.INC file to see all the options.

The other way to set the configuration bits is to write a hex value to the appropriate configuration register, as you are trying to do.
The syntax to do it this way is
Rich (BB code):
  __CONFIG _CONFIG2H,0x0E ;Note the double underline before the CONFIG!
Once you settle on one method of setting the configuration bits you must stick with it all the way through. You can't mix them and set some bits with the CONFIG command and others with the __CONFIG command.
 

Thread Starter

Shreder001

Joined Mar 7, 2009
22
Ok I did that, now i have a new prob. Here is my program now:

#include <p18F2431.inc>
CONFIG OSC = HS
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRTEN = ON
CONFIG BOREN = ON
CONFIG BORV = 20
CONFIG WDTEN = OFF
CONFIG HPOL = LOW
CONFIG LPOL = LOW
CONFIG LVP = ON
org 0000


BANKSEL TRISA
CLRF TRISA

BANKSEL PORTA
BSF PORTA,1


end

I can build it now, but RA1 is not turning on. Any thoughts?
 

AlexR

Joined Jan 16, 2008
732
PortA can be configured as either an analog port or a digital port. It defaults to analog so to use it as a digital port you have to set appropriate register (clear ansel0 I think should do it).
 
Top