pins 3,4,5 on every port not working

Status
Not open for further replies.

gabeNC

Member
I'm pretty sure this is a rookie mistake but I can't quite figure it out. Even tried the "wizard" in Sourceboost to make sure I wasn't doing anything completely stupid with the ADCON registers. Using a 16F877 and have every pin digital and out (except for RA4), driving a 8x8 RGB array. 8 transistors on the column drivers etc. Just ordered some shift registers for later but for now i'm just learning. Here's the code

Code:
#include <system.h>

//Target PIC16F877 configuration word
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _HS_OSC & _CP_OFF

//Set clock frequency
#pragma CLOCK_FREQ    4000000

void ALL_OFF(int delay)
    {
    porta=000000;
    portb=00000000;
    portc=00000000;
    portd=00000000;
    porte=00000000;
    delay_ms( delay );
    }

void ALL_ON(int delay)
    {
    porta=111111;
    portb=11111111;
    portc=11111111;
    portd=11111111;
    porte=11111111;
    delay_ms( delay );
    }
    
void main( void )
{
    trisa = 0x00;        //Configure ports
    trisb = 0x00;
    trisc = 0x00;
    trisd = 0x00;
    trise = 0x00;

    //Configure A/D pins
    adcon1 = 0x06;

    porta = 0x00;    //Initialize ports
    portb = 0x00;
    portc = 0x00;
    portd = 0x00;
    porte = 0x00;
                
    //Endless loop
    while( 1 )
        {
        ALL_OFF(500);
        ALL_ON(500);
        }
        
}
Here's what the sim shows.




thanks!
 
gabeNC

I just run this code in boost ide and it turns on the led blocks and off,,,,
Iam only just starting to learn boostC so prob not much help to you
Have you checked your hardware ie: What crystal are you using,The config word is set to high speed crystal in your code
Edit : Have just noticed somthing that when using binary it is written like this portb=0b111111111;

Bernie
 
Last edited:
I have just found this tutorial with some simple working code might help you,,, I am going to get into it when i have more time

**broken link removed**

Bernie
 
Thanks Bree,

After your first post I checked that and it was the 0b<value> omission. That's a little embarrassing to miss something like that .

Kinda weird that the PORTA-E registers were set to C7 without the explicit binary "flag" (see attached pic), maybe I was hoping for a syntax error instead hahaha.

**broken link removed**
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…