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.

PIC32 pin config problem?

Status
Not open for further replies.

nick703

Advanced Member level 1
Joined
Oct 17, 2011
Messages
422
Helped
21
Reputation
44
Reaction score
22
Trophy points
1,298
Location
surat
Activity points
3,987
I have completed rotary encoder configuration to toggle led to other pin of pic32mx575f256h.
in given datasheet (diagram is below ) i have configure micro controller pin no. 2 & 3 (RE6 AND RE7) to the encoder. and output to pin no.64 % 63 (RE3 AND RE4). every thing working right. but when i chenged encoder to pin no. 17 & 18 (RB6 AND RB7) so output to led is not toggling.
and i also marked that even i try to all black part (means 5v tolerant) of pic pin as a input of encoder then working perfectly .

PIC32MX575F256H-pinout.jpg

- - - Updated - - -

hear is the code .

Code:
#INCLUDE<plib.h>
  
#define mLED1on()  (LATESET = BIT_4)
#define mLED1off()  ( LATECLR= BIT_4)
#define mLED2on()  (LATESET = BIT_3)
#define mLED2off()  (LATECLR = BIT_3)

  
int oldvalue = 0;
  
void InitializePorts(void)
{
    TRISEBits.TRISE6 = 1 ;                  // make as a input for encoder
    TRISEBits.TRISE7 = 1 ;                  // make as a input for encoder
    TRISEBits.TRISE3 = 0 ;                  // make as an output for led1
    TRISEBits.TRISE4 = 0 ;                  // make as an output for led2
    
    return;
}

void InitializeLed(void)
{
    mLED1off();
    mLED2off();
    return;
}

void Encoder (void)
{
    int newvalue = 0 ;
    int value = 0 ; 
    
    newvalue = PORTE ;                           // read the current port status
    value = newvalue ^ oldvalue ;                     // flag each port bit that has changed

    if(value & 0x40)                        
    { 
        if (newvalue & 0x40)                    
        { 
            if (newvalue & 0x80)                 
            { 
                mLED1on() ;            
            } 
            else                           
            { 
                mLED2on() ;          
            } 
            
            Delay(20); 
           
        }
    }
    oldvalue = newvalue;                             // save current port status
    return;
}

void main(void)
{
    InitializePorts();
    InitializeLed();
    while(1)
    {
        Encoder();
    }
}
that working perfect but not other port like portb and also configured portb as same as port e.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top