Continue to Site

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.

Junebug Tip & Trick #1, Using the DIP switch as a 4 bit mode switch

Status
Not open for further replies.

blueroomelectronics

Well-Known Member
Well it's beta but I always enjoy sharing ideas and always fun to have food for thought.
This code snippet will be in the next issue of JPUG but I thought I'd share it here for review.
It uses the debug pins and USART pins and I'll write a routine to show the status on the Junebugs LEDs.
It also depends on the 4.7K pulldowns on DIP switch switches 2,3,4,5 and the Junebug programmer normally floats PGC & PGD after programming.
Code:
        bcf     INTCON,RBIF     ; enable weak pullups on PORTB
GetDIP  movf    PORTB,W         ; DCxAxxBx 
        andlw   b'11010010'     ; DC0A00B0 (mask)
        btfsc   WREG,1          ; is B zero?       
        bsf     WREG,5          ; DCBA00B0
        swapf   WREG            ; 00B0DCBA
        andlw   0x0F            ; 0000DCBA
D = RB.7
C = RB.6
B = RB.1
A = RB.4

Note: one of the really neat features the 18F have over the 16F is W is also a register (WREG)...
 
Last edited:
hi Bill,
Is that 'weak pull ups' on PORTB correct, should it be bcf INTCON2,RBPU

Tried with the new toy.;)
Hope you got the email OK.

Regards
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top