Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

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
 

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
i have added the line but same result means that the pic mcu is damadge or the assembler is courpt
 

Are you sure your PIC is 16F84 and not PIC 16F84A? Did you connect the RC oscillator correctly?
 
  • Like
Reactions: d@nny

    d@nny

    Points: 2
    Helpful Answer Positive Rating
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
Is my code 100 % correct?
 

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
how to change it crystal do i need to put XT in place of RC as i am driving on 8 MHz crystal
 

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
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
 

Just to let you know, to use crystal oscillator at 8MHz, change:
Code:
__config _RC_OSC & _WDT_OFF & _PWRTE_ON
to
Code:
__config _HS_OSC & _WDT_OFF & _PWRTE_ON

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top