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.

P24FJ64GB002, output port not changing state

Status
Not open for further replies.

drkidd22

Member
Hello,

I have the below code and I'm having some issues. Only ms1 changes state when I change the port output from logic high to logic low or the other way around.

For ms2 when I have the output set to logic low the DMM reads 10mV. When I set the logic output of ms2 to high the DMM reads 60mV. The pins are not connected to anything right now and the chip is running ok so far on other ports, I'm running a stepper motor with it and driving a couple of LEDs, but the ms2 pin has issues?

Not sure if my configuration bits are incorrect, but I can't get this running as it's supposed to right now. Any help will be appreciated.


Code:
#define FCY 8000000UL 
#include <P24FJ64GB002.h>  
#include <libpic30.h> 
     
_CONFIG1( FWDTEN_OFF  & ICS_PGx1 & GWRP_OFF & GCP_OFF & GWRP_OFF & JTAGEN_OFF)   
_CONFIG2( POSCMOD_NONE  &   I2C1SEL_PRI & IOL1WAY_ON & OSCIOFNC_ON & FCKSM_CSDCMD  & FNOSC_FRC & PLL96MHZ_OFF & IESO_OFF)  
_CONFIG3(SOSCSEL_IO) //Fast Internal RC (FRC) Oscillator 8MHz Clock Source 


//Defines  
#define                   ms1                      LATBbits.LATB7  
#define                   ms2                      LATBbits.LATB8    
  
main ()  
    {  

TRISBbits.TRISB7 = 0; 
TRISBbits.TRISB8 = 0; 
  
   AD1PCFG = 0xFFFF;          //All pins are digital 
     
    //Output Ports      
    TRISBbits.TRISB7 =   0;      //Set ms1 port as output      
    TRISBbits.TRISB8 =   0;      //Set ms2 port as output 
     
    //Output ports initial states      
         ms1 = 0;         
         ms2 = 0;    
         
         while (1)          
                   {                             
                         ms1 = 1;                             
                        ms2 = 1;                         
                   }//endWhile }
 
Looking at the data sheet, the USB module shares one of those pins. You might need to make sure that is disabled, but I would have thought that it was disabled by default.

Can you post the compiled version of the code to make sure that the compiler isn't doing anything silly.
 
It's also shared with the JTAG port but you have that disabled in your configuration bits.

Try hooking up to a pin that you know works. It is possible that you damaged a pin while prototyping. It's also possible that the MS2 pin on your Allego IC may be damaged which in turn damaged your PIC pin. Also make sure that every pin on the PIC that is supposed to have a GND or Vdd connection is hooked up properly. Odd things can happen if you forget to hook up even a single supply pin.
 
Last edited:
Replacing the chip fixed this problem with ms2. So I learned that I gotta be more careful using this chips, maybe use a esd strap which I have, but didn't use, plus I have rugs in my house, so esd might have killed some of the other chips. Not sure why only that one pin wasn't working properly. I got 5 samples from microchip and I burned or damaged the first four somehow. I'll prob start a new threat on how to use the stepper motor now that I have it working properly. Basically I'm going to be using it to simulate open it a door 90 degrees, wait for a couple of secs and then reverse the stepper to close the door. Thanks for everyone that's been helping me out. I've learned a lot.

@phalanx I saw your post in microchip forum, lol, I post in as many forums as I can to see how other people do different things.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top