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.

16F88 RB3 as input problems.. Stuck at 0V

Status
Not open for further replies.

mramos1

Active Member
I have a circuit where I use RB0-5 as output and input. But RB3 wants to just stay low (all the rest work 0,1,2,4,5,6).

Ohm'd it all out, all clean, no shorts and all connected, meter lights LED as well.

When I look at LED (RB3) with it running, it does not light, I read 0vdc as well. I tried CCP1CON =0. I give. Here is the init code in MikroBASIC.

Basically the registers are the same as ASM.

If I had a good ASM delay routine (mS and uS for all the different speeds I jump between) and liked to read the OSCCON/register stuff I would just go to ASM. I seem to always end back up like this :)

Thanks for any help. Also, hookup for all 6 pins (all are the same and all but RB3 work fine). I have PIC pin to resistor to LED to ground. switch across LED and using weak pullup. I thought maybe the LED and weak pullups might be the problem at one point, but why RB3 only?

EDIT: Making another game show buzzer for the kids :) Figure I would mention that as the code attached.

Code:
'*****   init code  ******
'16F88
    CMCON=7             'make PORTA digital I/O
    OSCCON=2            ' 31.25Khz clock internal RC OSC
    CCP1CON=0           'kill CPP mode    <-------------  no help
    intcon=0               'interupt are disabled
    ansel=%00000000     'all ports are in digital mode.

'***** rest of code if anyone wants to see more  *****
'***** I think it is in the chip setup   I tested LED in circuit as well ****
main:
    TRISB = 0           ' Configure pins of PORTB as output
    TRISA = %10000001   ' set porta for 0 = quix master and 1/2 out tp buzzer
    PORTB = %00000000   ' portB outputs to light LED
    timec=10000         ' set coutdown time to 10 seconds 10*1000
    setbit(porta,3)     'turn on GAME POWER LED

'FLASH LEDS and WAIT ON GAME MASTER SWITCH
    do
        portb = %00000000     'flash LED off
        delay_ms(100)
        portb = %11111111     'all LEDS on
        delay_ms(100)
    loop until porta.0 = 0     'wait for game master to start

'START COUNT AND WAIT FOR USER INPUT ON PORTB
    TRISB = %11111111   'set portb as input for the game.
    OPTION_REG.7 = 0    ' turn on weak pullups
    tmp=portb
    tmp=0               'zero PORTB variable
    co=0                'zero co (counter)
    do
          tmp=portb
'          tmp= tmp or 0xc0          'mask off unused portb 6-7
          if tmp <> %11111111 then  'see if a switch is pushed
             tmp = tmp xor 0xff     'if flip the bits to light LED
             co = timec
          end if
          delay_ms(1)
          co=co+1                   'counter (should be 1)
    loop until co >= timec

'SOUND BUZZER
    for co = 1 to 100
          delay_ms(1)
          setbit(porta,1)
          clearbit(porta,2)
          delay_ms(1)
          setbit(porta,2)
          clearbit(porta,1)
    next co

'SHOW WINNERS LED
    TRISB = %00000000
    clearbit(Porta,3)
    do                             'flash winning LED
        portb = %00000000
        delay_ms(250)
        portb = tmp
        delay_ms(250)
    loop until porta.0 = 0

goto main
end.
 
Last edited:
Starting to like the Atmels again..

Mike, LVP fixed RB3, now RB0 is broke (gounded; look like 0 and 3 are CCP related). I set the program to do CCP on RB3 and I can disable RB3. It has an RB3 as I/O enable. But I do not see one for RB0.. The PCB is done, so I do not want to slide all the ports down one and shift the byte in software. Otherwise that would be a cheap fix..

Just need RB0 as I/O. Arrghh! :)
 
It seemed so simple. :) I think I will be going back to that method.

Mike: Flipping back to the 16F628A as I went from that to the 16F88 to play with ICD2. I did find a bug with it.

Maybe that will help, but I hope RB0 is not another input only of something. Off to read 16F628A pdf..
 
So no help on getting RB0 working as I/O. :p Pommie!

I looked at the 16F628a.PDF and said wait, I have 3 kids and 1 wife (4 buttons).. Why do I need 6 players.

added a tmp = tmp or 0xc1 and killed RB0 (and RB6/7 unused)..

Life is good. We played with it for a couple hours. Was fun.

If we use it again, I will drop an LED across the switch in the handle as it is easier to see who hit the button.. Was hard to look at the board and pick the winner. LEDs too close. Or a 7/8 segment LED and show the handle number on the board.

If the game show guys come back here I will post it for them. :)

Guess I was bored over the holiday.
 
The only thing that can effect RB0 would be the CCP/PWM module but it shouldn't be operational as CCP1CON=0 . As a test, can you change the configuration bit (clear Config bit 12) and see if the problem moves to RB3. Did it work ok before you turned off LVP?

BTW, why are some of the system labels lower case, such as ansel?

Mike.
 
Pommie said:
The only thing that can effect RB0 would be the CCP/PWM module but it shouldn't be operational as CCP1CON=0 . As a test, can you change the configuration bit (clear Config bit 12) and see if the problem moves to RB3. Did it work ok before you turned off LVP?

It did work. Then I flipped LVP and CPP1COM=0 thinking that would fix RB0 and flipped CPP is the MPLABS to RB3 as it was working now.. And no go.
I will put a .asm and .endasm and do it in assembler, maybe that BASIC has a bug.

BTW, why are some of the system labels lower case, such as ansel?

I grabbed it from another program I did with the 16F628A and pasted it :) Being lazy.

For now I masked the bit and we had a lot of fun with it. But I would like to fix it in software. The .PDF says it can be used as I/O.. I dropped the F88 and went to the F628A (cheaper). I am added LEDs to the handles tonight (easier to figure out the winner).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top