Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

pic16f84 bit command not working

Status
Not open for further replies.

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
the bsc portb , 0 should only hi RB0 but the whole port i mean the 8 pins of portb going to hi with this command.



processor 16f84
include <p16f84.inc>
__config _RC_OSC & _WDT_OFF & _PWRTE_ON
; Please insert your code here.
J equ 21h
org 00h
main:
banksel TRISB
movlw B'00000000'
movwf TRISB
banksel PORTB
bsf PORTB , 0
fin:
goto fin

end



the whole portb becomes hi with this command bsf
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
Change your code to this:

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
processor 16f84
include <p16f84.inc>
__config _RC_OSC & _WDT_OFF & _PWRTE_ON
; Please insert your code here.
J equ 21h
org 00h
main:
banksel TRISB
movlw B'00000000'
movwf TRISB
banksel PORTB
clrf PORTB
bsf PORTB , 0
fin:
goto fin
 
end



This should work.

You can see that I added the line:

Code ASM - [expand]
1
clrf PORTB



This makes sure that before you do anything on PORTB, the initial value that it holds is cleared.

Hope this helps.
Tahmid.
 
  • Like
Reactions: d@nny

    d@nny

    points: 2
    Helpful Answer Positive Rating

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
i have added the line but same result means that the pic mcu is damadge or the assembler is courpt
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,273
Trophy points
1,413
Location
Southwest, USA
Activity points
62,486
How are you programming the PIC16F84? With what programmer?
After programming have you ran a "verify" to ensure the program is correctly stored in the flash?
What RC values are you using for your RC OSC?
 
  • Like
Reactions: d@nny

    d@nny

    points: 2
    Helpful Answer Positive Rating

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
Is my code 100 % correct?
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
It looks okay and simulates okay. If your hardware is alright, it should work. Take a look at your RC oscillator, if you configured it correctly, etc. You might try with a crystal and change the config bits in the code to a crystal.

Hope this helps.
Tahmid.
 
  • Like
Reactions: d@nny

    d@nny

    points: 2
    Helpful Answer Positive Rating

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
how to change it crystal do i need to put XT in place of RC as i am driving on 8 MHz crystal
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,273
Trophy points
1,413
Location
Southwest, USA
Activity points
62,486
how to change it crystal do i need to put XT in place of RC as i am driving on 8 MHz crystal
Actually you need to use the HS for an 8MHz, refer to the appropriate datasheet for details.
 
  • Like
Reactions: d@nny

    d@nny

    points: 2
    Helpful Answer Positive Rating

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
actually i am making a digital combination lock and multisim only have pic16f84. in multisim pic work ok on 8 KHz . i have tried that code in mplab and it is working fine. The clrf also working fine in mplab. now on 8khz it is also fine with multisim. Thank you so much for help me
bye
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top