Olin Lathrop wrote: > > > status equ 0x07 ; status register > > rp0 equ 5 ; > > carry equ 0 ; the carry bit > > > > ;; port B configuration > > portb equ 0x06 ; I/O port B > > serio equ 7 ; the serial i/o is RB7 > > sda equ 5 ; SDA is RB5 > > scl equ 4 ; SCL is RB4 > > > > trisb equ 0x86 ; trisb is the direction register for port > B > > DON'T DO THIS!!!! (This must be about the 20th time this has come up in the > last year). Horses for courses. Beginners may not know about or understand "include" files yet. I certainly wrote code this way when I first started with MPALC. I missed the STATUS definition when I wrote back last time. It should be defined as... status equ 0x03 Also your config value is not valid because the Code Protect bits are trying to be set in opposite values. __config 0x1ff9 It should be... __config 0x3ff9 Now, if you decide to use an "include" file for this project this is how your program start could look like.... ;; program to send 'A' on the serial port ;; list f=INHX8M, p=16F84 #include "p16f84.inc" __config _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC ; ; PORTB BIT DEFINITIONS ; serio equ 7 ; the serial i/o is RB7 sda equ 5 ; SDA is RB5 scl equ 4 ; SCL is RB4 ; ; RAM DEFINITIONS ; CBLOCK 0x0C sobuf ; serial output buffer sibuf ; serial input buffer sctr ; counter for bits to output to serial port delay ; wait counter for serial i/o ENDC ;; beginning of the program ;; jump over the interrupt vector org 0 init goto start If you look inside the MPLAB directory you will see a whole list of *.inc files. If you open 'p16f84.inc' using 'Notepad', you will see that all the internal registers and thier bits are defined for you. Because you included this file with your source code, MPASM will assemble this file and your source code and thus have all the register data it needs. This means you don't have to specifically define each one yourself. One thing to take note of with this approach is that inside the include files, the registers are defined in UPPERCASE so you either have to type the register names etc. in upper case, or turn off the "case sensitivity" option. Failing to do this will result in errors produced. Try both ways to see what happens. eg. status,rp0 should be STATUS,RP0 with case sensitivity active. You will probably need to have a look at these files if you use them so that you make sure your register definitions are the same as the ones written. eg. you might define the OPTION register as "OPTION" in your code and it is defined as "OPTION_REG" in the include file. This will create an error. Try it and see. The CONFIG information is also written in this file and makes it easier for you to set the FUSE bits. Looking above, you can see how much easier it is to understand now. Also, I used a CBLOCK statement which sets an address for your RAM definitions. You can see that it starts at address 0x0C which is the start of the RAM address space in the 16F84. eg CBLOCK 0x0C. Just enter your RAM names in between the CBLOCK and ENDC statements and MPASM will automatically assign incremental addresses for each one. To verify this, have a look at the list file (*.lst) produced after assembly and you will see the address data listed next to each definition. Have a look at the MPASM help file and look up CBLOCK for more info. -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads