Programming a PIC help required.

Thread Starter

macke

Joined Oct 12, 2014
65
Hi I am a complete novice and I am trying to programme a PIC16F876 with a source code.

I tried using MPLAB X IDE V3.30 on a MAC, but it wouldn't compile or debug, so I tried MPLAB IDE V8.10 on Windows XP. I am using a PICKIT 2, and both the chip and programmer are recognised by the software. I understand that the source code is in TASM, but MPASM is expected, so I am assuming it doesn't like the syntax.

I have attached a copy of the errors.

Is there a list of differences between TASM and MPASM or can anyone help me to correct/convert it please.

Ken
 

Attachments

dannyf

Joined Sep 13, 2015
2,197
understand that the source code is in TASM, but MPASM is expected, so I am assuming it doesn't like the syntax
You have two options.
1. Get a tasm compiler and be done with it.
2. Understand what the task code is doing and recode the logic in a tool chain that you are comfortable with.
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
For starters, drop the dot before equ. Then see your errors. Or use the CBLOCK construction:
Code:
          CBLOCK        0x20
          Reg1
          Reg2
          Etc.
          ENDC
Not sure about $xx for a location. I just use 0x20 etc. (I typically use decimal as my default radix). Suspect that may be OK. Once you get your registers recognized.
upload_2016-5-31_6-32-56.png
Try banksel <name>

John
 

jpanhalt

Joined Jan 18, 2008
11,087
I tested the CBLOCK change, and that helped. Also noticed that you try to define a bit in PORTC with an equate. Changed that to a #define (i.e., a simple substitution) and fixed more errors.
Code:
     #define   DI        0x07
     #define   DO        0x06
     #define   SDATA     0x04
     #define   SCLK      0x03
;DI:         EQU $07        ; eeprom input bit
;DO:         EQU $06        ; eeprom output bit
;SDATA:      EQU $04        ; serial EE data line (PORTC)
;SCLK:       EQU $03        ; serial EE clock line (PORTC)
1) A major remaining error is your bank selection. Check the datasheet and find out how to do it for that device.
2) Another major error is overwrites. Again, the datasheet and .inc file may help you there.
3) Finally, MPASM does not seem to like the dotxyz construction, so I changed .END to just END.

John
 

Thread Starter

macke

Joined Oct 12, 2014
65
Thank you for all your help on this. I will correct as suggested and read up on how to code. Then see if I can rewrite it to suit. Not sure if I can as it may be beyond me as I have never written anything in ASM before, but I have the circuit made so if not it will have to be a bin job.

Thank you again

Ken
 
Top