BANKSEL TRISA
include "P16F819.inc"
LIST p=16F819
include "P16F819.inc"
__config _INTRC_IO & _WDT_OFF & _LVP_OFF
org 0x0000
init
BANKSEL TRISA ;select bank 1
clrf TRISA ;PORTA all outs
movlw b'00000010'
movwf TRISB
BANKSEL PORTA ;select bank 0
clrf PORTA
clrf PORTB
spiinit bsf PORTB,0 ;CS high
BANKSEL SSPSTAT ;select bank 1
movlw b'11000000' ;init SPI Master
movwf SSPSTAT
BANKSEL SSPCON ;select bank 0
clrf SSPCON
movlw b'00000010'
movlw SSPCON
bsf SSPCON,SSPEN
bsf TRISA
;program to turn diodes on PORTB on and off
;versio=8.0 date: 18\1\2008 Name:mss
PROCESSOR 16F84A
#INCLUDE "P16F84A.INC"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x00
banksel TRISA
movlw 0xff
movwf TRISA
CLRF TRISB
banksel PORTA
CLRF PORTB
ask BTFSS PORTA,0
GOTO ask
movlw 0xff
movwf PORTB
CALL delay
CLRF PORTB
CALL delay
goto ask
delay
movlw .130
movwf 0x0c
CLRF 0x0d
loop decfsz 0x0d,1
goto loop
decfsz 0x0c,1
goto loop
return
end
paste your program here
Easier way: Simply click on the # in the menu immediately before pasting your code.bananasiong said:the text 'code' in the square bracket, followed by the program code, then '/code' in the square bracket.
So go to Advanced if you're going to post code. Pretty simple fix.bananasiong said:I use quick reply usually
BTW, I can't see any menu in my reply page. There are only Title, Message, Post Icons and Additional Options. Anything missing?
I went through it and neatened a few things up but found nothing terribly wrong with it. As far as I can see it should work if it's wired correctly.m_saeed_soliman said:thanks you all for your advice
but i still have the problem
this is my code , if you find anyhting wrong with it please tell me
;program to turn diodes on PORTB on and off
;versio=8.0 date: 18\1\2008 Name:mss
LIST 16F84A
#INCLUDE "P16F84A.INC"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
cblock 0x0c
d1,d2
endc
org 0x0000
BANKSEL TRISA ;bank 1
movlw 0x01 ;porta all outs except bit 0
movwf TRISA
clrf TRISB ;portb all outs
BANKSEL PORTA ;bank 0
clrf PORTA ;clear porta
clrf PORTB ;clear portb
ask btfss PORTA,0 ;check switch?
goto ask
movlw 0xff ;leds on
movwf PORTB
call delay ;delay
clrf PORTB ;leds off
call delay ;delay
goto ask ;go again
delay movlw 0x82 ;$82 = 130 decimal
movwf d1
clrf d2
loop decfsz d2,1
goto loop
decfsz d1,1
goto loop
return
end
I didn't have a 16F84A but I did have a 16F84 in the junk box, so I breadboarded up a circuit similar to what I assume you're using.m_saeed_soliman said:thanks you all for your advice but i still have the problem
this is my code , if you find anything wrong with it please tell me
LIST P=PIC16F84
#INCLUDE "P16F84.INC"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
cblock 0x0c
d1,d2
endc
org 0x0000
BANKSEL TRISA ;bank 1
movlw 0x01 ;porta all outs except bit 0
movwf TRISA
clrf TRISB ;portb all outs
BANKSEL PORTB ;bank 0
movlw 0xff ;turn LEDs off (set portb)
movwf PORTB ;clear portb
ask btfss PORTA,0 ;check switch?
goto ask
call delay ;delay
clrf PORTB ;leds off
call delay ;delay
movlw 0xff ;leds on
movwf PORTB
goto ask ;go again
delay movlw 0x82 ;$82 = 130 decimal
movwf d1
clrf d2
loop decfsz d2,1
goto loop
decfsz d1,1
goto loop
return
end
;program to turn diodes on PORTB on and off
;versio=8.0 date: 18\1\2008 Name:mss
PROCESSOR 16F84A
#include "p16f84a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x00
BANKSEL TRISA
movlw 0xff
movwf TRISA
CLRF TRISB
BANKSEL PORTA
movlw 0xff
CLRF PORTB
ask BTFSS PORTA,0
GOTO ask
movlw 0xff
movwf PORTB
CALL delay
CLRF PORTB
CALL delay
goto ask
delay
movlw .130
movwf 0x0c
CLRF 0x0d
loop decfsz 0x0d,1
goto loop
decfsz 0x0c,1
goto loop
return
end
Executing: "D:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84A "ledsblink.asm" /l"ledsblink.lst" /e"ledsblink.err" /o"ledsblink.o"
Message[302] D:\DOCUMENTS AND SETTINGS\XPPRESP3\MY DOCUMENTS\MPLAB WORK\LEDSBLINK.ASM 9 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\DOCUMENTS AND SETTINGS\XPPRESP3\MY DOCUMENTS\MPLAB WORK\LEDSBLINK.ASM 10 : Register in operand not in bank 0. Ensure that bank bits are correct.
A language-plugin exception occurred and was logged.
BUILD FAILED: Sat Jan 19 09:37:20 2008
Message[302] D:\DOCUMENTS AND SETTINGS\XPPRESP3\MY DOCUMENTS\MPLAB WORK\LEDSBLINK.ASM 9 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\DOCUMENTS AND SETTINGS\XPPRESP3\MY DOCUMENTS\MPLAB WORK\LEDSBLINK.ASM 10 : Register in operand not in bank 0. Ensure that bank bits are correct.
A language-plugin exception occurred and was logged.
BUILD FAILED: Sat Jan 19 09:37:20 2008
m_saeed_soliman said:thanks all
but no one understood my problem
the Mplab did not say my program is correct
and this is the message Mplab tells me
Message[302] D:\DOCUMENTS AND SETTINGS\XPPRESP3\MY DOCUMENTS\MPLAB WORK\LEDSBLINK.ASM 9 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\DOCUMENTS AND SETTINGS\XPPRESP3\MY DOCUMENTS\MPLAB WORK\LEDSBLINK.ASM 10 : Register in operand not in bank 0. Ensure that bank bits are correct.
A language-plugin exception occurred and was logged.
C:\MCU\16F84A\flop\bong
bananasiong said:Oh it appears to be different here.
Here's the steps, in case you don't know:
1. Select Project/Project Wizard
2. Step One: Select your device from the list.
3. Step Two: Select a language toolsuite. For assembler, the Active Toolsuite should be "Microchip MPASM Toolsuite". Don't change anything else on that page. Hit Next.
4. Step Three: Create New Project File. Browse to where you want your project stored. Create a directory for it if you want. If you do, move into the directory before naming the project so the project is created inside the directory. You would end up with a line like this example project named "bong" in a directory named "flop":
Code:
C:\MCU\16F84A\flop\bongName the project and hit Next.
5. Step Four: Add existing files to your project. If you have any asm source files already in the directory that you want added to the project, add them now. Hit Next.
6. Finish
Now select your programmer. If you haven't added a source file yet go Project/Add New File to Project and name your new empty xxxx.asm file.
That's it. You probably already knew all that, but maybe not. Impossible to tell from here.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?