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.

Explorer 16 PORTA LED problem

Status
Not open for further replies.

aj9999

Junior Member level 3
Joined
Feb 5, 2010
Messages
28
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
Missouri
Activity points
1,456
I am using MPLAB/C30 with an explorer16 board and a PIC24fj128GA010 PIM. I am attempting to flash the LEDs attached to port A. I can flash any of the LEDs independently but when I try to flash more than one of them only the first one listed in the code will work. In the code below RA0 will flash but not RA1. If I reverse the order so that RA1 is first then RA0 will work but not RA1 will. If I use PORTA = 0x03 then it works so it appears to be a problem with the PORTAbits.RA? command but i dont know why.

Code:
#include <p24FJ128GA010.h>
#include <16BitDelay.h>

int main()
{
  AD1PCFG = 0xffff;
  TRISA = 0x00;
  PORTA = 0x00;

  while(1)
  {
    PORTAbits.RA0 = 1;
    PORTAbits.RA1 = 1;
    msDelay(500);
    PORTAbits.RA0 = 0;
    PORTAbits.RA1 = 0;
    msDelay(500);
  }
}
and from the delay.h file
Code:
int x=0;

void msDelay(int d)
{
  while (d>0)
  {
    for (x=0; x<500; x++)
    {
    }
  d--;
  }
}
 

Use "LATA" for outputtting ...use PORTA for reading
 

LATA worked, but i dont know why. I have used PORT numerous times before without issue. I wonder if it has somthing to do with successive read/modify?
Well thanks for setting me on the correct path.[/code]
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top