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
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
I still have errors .. I'm a beginner in this language . please could someone modify it .
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
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
list p=16f877A #include <P16f877A.INC> ORG 0x00 bcf STATUS , RP0 clrf TRISD clrf TRISB clrf TRISA clrf TRISC bsf STATUS , RP0 loop : movlw 0xf0 movwf PORTD movlw 0xff movwf PORTA movlw 0x0f movwf PORTC movlw 0xff movwf PORTB goto loop END HI i have written this code and did not see anything wrong with it when put the .hex file into the proteus the program wont work can you help me ?
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.