Programming a PIC help required.

Discussion in 'Embedded Systems and Microcontrollers' started by macke, May 31, 2016.

  1. macke

    Thread Starter Member

    Oct 12, 2014
    65
    2
    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
     
  2. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,672
    899
    It might be more helpful if your show your code.

    John
     
  3. macke

    Thread Starter Member

    Oct 12, 2014
    65
    2
    Hi code attached

    Ken
     
  4. dannyf

    Well-Known Member

    Sep 13, 2015
    1,767
    357
    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: May 31, 2016
  5. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,672
    899
    For starters, drop the dot before equ. Then see your errors. Or use the CBLOCK construction:
    Code (ASM):
    1.  
    2.           CBLOCK        0x20
    3.           Reg1
    4.           Reg2
    5.           Etc.
    6.           ENDC
    7.  
    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
     
  6. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,672
    899
    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 (ASM):
    1.  
    2.  
    3.      #define   DI        0x07
    4.      #define   DO        0x06
    5.      #define   SDATA     0x04
    6.      #define   SCLK      0x03
    7. ;DI:         EQU $07        ; eeprom input bit
    8. ;DO:         EQU $06        ; eeprom output bit
    9. ;SDATA:      EQU $04        ; serial EE data line (PORTC)
    10. ;SCLK:       EQU $03        ; serial EE clock line (PORTC)
    11.  
    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
     
  7. macke

    Thread Starter Member

    Oct 12, 2014
    65
    2
    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
     
  8. macke

    Thread Starter Member

    Oct 12, 2014
    65
    2
    Hi what TASK COMPILERS SHOULD I TRY?
     
  9. dannyf

    Well-Known Member

    Sep 13, 2015
    1,767
    357
    Whichever tasm compiler that work for the MCU should be fine if you want to code in assembly. Or whatever tool chain you are comfortable working with. Doesn't have to be in assembly.
     
Loading...