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.

[SOLVED] need help with PIC :)

Status
Not open for further replies.

ernpao

Full Member level 1
Joined
Sep 16, 2010
Messages
98
Helped
26
Reputation
52
Reaction score
22
Trophy points
1,298
Activity points
2,043
Hi, I'm new to micro controllers and have started learning programming PICs using assembly language and I was wondering if anybody can help me figure out with something:

I'm trying to use pin RB0 on the 16F877a as my interrupt source to increment the contents of a register (general purpose register named SECTION_SELECT) whenever I press a button connected to RB0 in my ISR and the main program moves the contents of SECTION_SELECT into port D. I tried simulating the code and it works fine, port D increments and returns to 0 after 5 presses. It basically counts from 0 to 5.

When I tried prototyping the circuit, port D doesn't go through the cycle properly. I even cleared the registers i'm using in my headers just to be sure, and put a delay in my ISR before the retfie instruction. Here's my ISR:


;**********************************************

MOVWF W_TEMP ;Copy W to TEMP register
SWAPF STATUS,W ;Swap status to be saved into W
CLRF STATUS
MOVWF STATUS_TEMP ;Save status to STATUS_TEMP register

;**********************************************

BTFSC MODE,0
GOTO SECTION_ZERO
INCF FSR
INCF SECTION_SELECT
BTFSC SECTION_SELECT,2
BTFSS SECTION_SELECT,0
GOTO EXIT
GOTO ISR_ALL

ISR_ALL BSF MODE,0
GOTO EXIT

SECTION_ZERO BCF MODE,0
MOVLW 20h
MOVWF FSR
CLRF SECTION_SELECT

;**********************************************
;EXIT ISR/RESTORE

EXIT BCF INTCON,1
SWAPF STATUS_TEMP,W ;Swap STATUS_TEMP register into W
;
MOVWF STATUS ;Move W into STATUS register
SWAPF W_TEMP,F ;Swap W_TEMP
SWAPF W_TEMP,W ;Swap W_TEMP into W

;**********************************************
CALL DELAY
RETFIE

Though since the code works fine in simulations, I'm thinking it's more of a problem with the hardware, though aside from the basic circuitry required by the PIC, all i've done is add a switch to RB0 to trigger the interrupt. Any ideas on why the circuit doesn't work on the breadboard? Thanks in advance :)
 

hi can anybody help to design pic 18f2550 universal usb remote controller, i have collectrd information from How-to: USB remote control receiver - Hack a Day but we design the remote should detect as com5 through usb and also the test condition from hercules software also passed but the remote button press means cannot received any responce in grider software so pls tell me how can select a remote i am try more than 5remotes but didnot detect anything so pls tellme any easy way to select the remote.?
 

port D doesn't go through the cycle properly.

thanks for that very informative description, :).

I would guess that the issue is with debouncing.
 
  • Like
Reactions: ernpao

    ernpao

    Points: 2
    Helpful Answer Positive Rating
Wow, I really didn't think debouncing was a serious matter. I added a debouncing circuit to my switch. The circuit works fine now thanks millwood :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top