Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Bizarre problem with Junebug LEDs

Status
Not open for further replies.

Gfaja

New Member
Same problem on the same line. Why are we setting those two bits as input? And not sure what you mean about debug enabled.. the debugger is connected if that's what you mean.
 

blueroomelectronics

Well-Known Member
RBPU needs to be cleared to enable the pullups.
Here's a working version of the code and it worked with the debugger, just make sure the DEBUG pulldown is selected.
Code:
; *** Junebug 18F1320 LED sequencer demo ***
; Flashes LEDs1 thru 6 from left to right forever
; DIP Switch (SW6) must have TUTOR on (SW6-1,2,3) all other switches off
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF

org 0x000            ; RESET vector
; INIT
INIT    movlw    0x72            ; 8MHz OSC
        movwf    OSCCON
        movlw     0x7F
        movwf     ADCON1      ; Set to all digital 
        movlw     b'00111111'
        movwf     TRISA        
        movlw     b'01111111'
        movwf     PORTA        
        movlw     b'00100101'
        movwf     TRISB
        bcf       INTCON2,RBPU     ; Enable pullups

MAIN    btfss     PORTB,RB2        ; is button #2 pressed?
        goto     LED3            ; yes?
LED4    movlw     b'10000000'        
        movwf     PORTA            ; LED4 on, 3 off
        goto     MAIN
LED3    movlw     b'01000000'        ; RB2 pressed
        movwf     PORTA            ; LED3 on, 4 off
        goto     MAIN            


END
 
Last edited:

Gfaja

New Member
Hm, all seems to be working. Still not sure exactly what was going wrong but it's working now. Thanks so much for the help
 

Gfaja

New Member
Actually I must have fucked up something soldering.

Code:
; *** Junebug 18F1320 LED sequencer demo ***
; Flashes LEDs1 thru 6 from left to right forever
; DIP Switch (SW6) must have TUTOR on (SW6-1,2,3) all other switches off
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF, DEBUG = ON

org 0x000			; RESET vector
; INIT
INIT	
		movlw 0x72
		movwf OSCCON			; Speed the clock

		movlw 0x7F
		movwf ADCON1      ; Set to all digital 

		movlw b'01111110'
		movwf TRISA
		
		movlw b'00000001'
		movwf PORTA		

		movlw b'00100101'
		movwf TRISB

		bsf   INTCON2,RBPU     ; Set pullups

MAIN	
		btfss PORTB,RB2			; Is button 2 pressed?
		goto LED6				; Yes?
		movlw b'10000000'
		movwf PORTA
		goto MAIN
LED6	movlw b'00000001'
		movwf PORTA
		goto MAIN

END
Middle button is unresponsive but when I have it run, it may flicker, so I'm not sure if there's something wrong with its connection. As I was typing this with the thing on my lap it started flickering, and now both are lit.

Any thing that you can think is likely to have been soldering improperly? I'm not wearing a wrist strap or anything but I can't really see it having that kind of affect.

**broken link removed**
 

blueroomelectronics

Well-Known Member
You must change the bsf to bcf
bcf INTCON2,RBPU

to enable pullups or the buttons will not work properly.

From MPLAB's debug, open a Watch window and watch PORTB, animate the program and press button #2 and you should see PORTB value changing.
 
Status
Not open for further replies.

Latest threads

Top