EmbDev.net

Forum: µC & Digital Electronics Help me with my code


Author: John Welo (Company: Welcomn) (librali)
Posted on:

Rate this post
0 useful
not useful
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 :


here is my code that I did but contain some errors :


list p=16F877a

#include <p16f877A.inc>



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 after clicked BUILD ALL button in MPLAB

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



Could someone please help solving this issue

thx

Author: TK (Guest)
Posted on:

Rate this post
0 useful
not useful
Hello,

you have to use a TAB for the first column and then you can place your 
code.
The first column only defines LABELs/MACROs.

TK

Author: Ottmar K. (wil1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi,
I hope the enclosure will help you
Wil

Author: Ottmar K. (wil1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi
it need not to much time to write the attached code
Wil

Author: John Welo (Company: Welcomn) (librali)
Posted on:

Rate this post
0 useful
not useful
I still have errors .. I'm a beginner in this language . please could 
someone modify it .

Author: TK (Guest)
Posted on:

Rate this post
0 useful
not useful
Then you might have problems with the project settings in MPLAB.
Selected the right device?
Used ASM instead of C?
>I still have errors ..
show them!

TK

Author: Ottmar K. (wil1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi John
My code is not perfect, but it works well - without errors (see picture 
"00_MPLAB_8.92.jpg"

Don't forget to choose in MPLAB-Menue:
"Configure"
  -> Select Device
    -> Choose in thre drop down menue "PIC16F877"

Why you don't use MPLABs build-in simulator "MPLAB SIM"? I'm sure it 
will be a better option than "proteus". Personally, I don't know this 
simulator "proteus". If you don't use MPLAB SIM, you will relinquishing 
to a lot of benefits!

Also recommended:
  Use in MPLAB the Debugger menue "MPLAB SIM"
    -> Settings
      ->Simulator Settings "4 MHz" (fosc)

Here are few more hints:
1. Read the datasheet PIC16F877 to understand/solve the functions
   implemented in the PIC or problems caused by your code
2. You can find a template in your MPLAB folder:
   Path: "MPLAB\MPASM Suite\Template\Code\16F877TEMP.ASM"
3. Also interesting: PIC16F877.INC with a lot of labels and constants in
   context with PIC-ASM
   Path: "MPLAB\MPASM Suite\p16f877.inc"
4. SHOW THE ERRORS occured in your code (you can attach them as a file)

Wil

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.