• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic 16f877A three leds toggles

Status
Not open for further replies.

librali

New Member
Greetings ,


I have to do a program code in PIC ASSEMBLY LANGUAGE using MPLAB and after that do simulation using PROTEUS . The program that should I write is to :

Toggle the LEDs every half second in sequence: green, yellow, red, green,...
Count cycles to obtain timing.
Use 4 MHz crystal for 1 microsecond internal clock period.


USING timer0 INT .

Here is what I did :

Code:
#include p16f877A.inc

cblock 0x70
  w_temp
  STATUS_temp
endc

push macro
  movwf w_temp
  swapf STATUS,w
  movwf STATUS_temp
endm

pop macro
  swapf STATUS_temp,w
  movwf STATUS
  swapf w_temp,f
  swapf w_temp,w
endm

  org 0X00
  goto start
  org 0X04
  goto Interkey

  org 0X05
start
  banksel TRISD
  clrf TRISD
  banksel ADCON1
  movlw 0X06
  movwf ADCON1
  movlw 0X90
  movwf INTCON
  banksel OPTION_REG
  bsf OPTION_REG,6
l nop
  goto l

Interkey
  banksel PORTA
  movf PORTA,w
  movwf PORTD
  bcf INTCON,INTF
retfie

end

---------------------

Here is what I got when compiled using MPLAB V8




Executing: "C:\Program Files (x86)\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F877A "ThreeLeds.asm" /l"ThreeLeds.lst" /e"ThreeLeds.err" /o"ThreeLeds.o"
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 1 : Found directive in column 1. (Code)
Error[108] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 1 : Illegal character :))
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 11 : Found directive in column 1. (endc)
Error[144] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 11 : Unmatched ENDC
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 21 : Found directive in column 1. (endm)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 33 : Found directive in column 1. (endm)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 35 : Found directive in column 1. (org)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 37 : Found opcode in column 1. (goto)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 39 : Found directive in column 1. (org)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 41 : Found opcode in column 1. (goto)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 43 : Found directive in column 1. (org)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 47 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 49 : Found opcode in column 1. (clrf)
Message[302] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 49 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 51 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 53 : Found opcode in column 1. (movlw)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 55 : Found opcode in column 1. (movwf)
Message[302] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 55 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 57 : Found opcode in column 1. (movlw)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 59 : Found opcode in column 1. (movwf)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 61 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 63 : Found opcode in column 1. (bsf)
Message[302] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 63 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 67 : Found opcode in column 1. (goto)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 71 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 73 : Found opcode in column 1. (movf)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 75 : Found opcode in column 1. (movwf)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 77 : Found opcode in column 1. (bcf)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 79 : Found opcode in column 1. (retfie)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 81 : Found directive in column 1. (end)
Halting build on first failure as requested.
BUILD FAILED: Mon Aug 15 19:59:46 2016


Could anyone please help me with this issue ?
 
Last edited by a moderator:

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Although you only have two errors... Nothing is wrong!!!
this line
#include p16f877A.inc
should read
#include <p16f877A.inc>

The brackets direct the compiler to the correct directory..

Also use list ( so the compiler knows the chip,,)
list p=16F877a
 

librali

New Member
Although you only have two errors... Nothing is wrong!!!
this line
#include p16f877A.inc
should read
#include <p16f877A.inc>

The brackets direct the compiler to the correct directory..

Also use list ( so the compiler knows the chip,,)
list p=16F877a

Thanks for your answer .. I modified it as you said but still got errors as you see .


Executing: "C:\Program Files (x86)\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F877A "ThreeLeds.asm" /l"ThreeLeds.lst" /e"ThreeLeds.err" /o"ThreeLeds.o"
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 1 : Found directive in column 1. (list)
Error[150] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 7 : Labels must be defined in a code or data section when making an object file
Error[150] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 9 : Labels must be defined in a code or data section when making an object file
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 11 : Found directive in column 1. (endc)
Error[144] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 11 : Unmatched ENDC
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 21 : Found directive in column 1. (endm)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 33 : Found directive in column 1. (endm)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 35 : Found directive in column 1. (org)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 37 : Found opcode in column 1. (goto)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 39 : Found directive in column 1. (org)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 41 : Found opcode in column 1. (goto)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 43 : Found directive in column 1. (org)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 47 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 49 : Found opcode in column 1. (clrf)
Message[302] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 49 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 51 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 53 : Found opcode in column 1. (movlw)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 55 : Found opcode in column 1. (movwf)
Message[302] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 55 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 57 : Found opcode in column 1. (movlw)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 59 : Found opcode in column 1. (movwf)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 61 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 63 : Found opcode in column 1. (bsf)
Message[302] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 63 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 67 : Found opcode in column 1. (goto)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 71 : Found directive in column 1. (banksel)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 73 : Found opcode in column 1. (movf)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 75 : Found opcode in column 1. (movwf)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 77 : Found opcode in column 1. (bcf)
Warning[203] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 79 : Found opcode in column 1. (retfie)
Warning[205] C:\USERS\WAQAS\DESKTOP\MYPROJ\THREELEDS.ASM 81 : Found directive in column 1. (end)
Halting build on first failure as requested.
BUILD FAILED: Mon Aug 15 22:56:46 2016
 

Wp100

Well-Known Member
Your original code builds fine for me; but if you simply cut and paste the code you will get those errors because the original code has lost its correct format.

If you look at those error messages , where it says Found directive or op code in column 1, then just add a Space before that instruction and it should build ok.

Not sure what that bit of code is supposed to do, as there are no comments with it to clearly indicate what the program logic is ?
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top