Hey everybody,
I'm trying to code my Microchip dsPIC33FJ with some fairly simple code. I don't know why it's not working though.
Here is my code:
But, for some reason, none of it is working? I can manually switch the pins. Commands like:
PORTAbits.RA2 = 0;
PORTAbits.RA2 = 1;
would leave RA2 high.
Additionally, I can copy and paste those lines hundreds of times and it works.
Oddly, though, when I simplify it into functions, it stops working.
For some reason, when I de-abstract the code and make it one long main, it then stops working again.
Any ideas?
I'm trying to code my Microchip dsPIC33FJ with some fairly simple code. I don't know why it's not working though.
Here is my code:
Code:
void initS2P(void)
{
TRISA = 0x00; // init all of A register as outputs
LATA = 0x00; // clear that bad boy out, just to be sure
}
void clockSR()
{
PORTAbits.RA2 = 1;
PORTAbits.RA2 = 0;
}
void updateLEDArray(int shift[8])
{
int bitNum;
for(bitNum = 7; bitNum == 0; bitNum--)
{
PORTAbits.RA3 = shift[bitNum]; // put bit on SER
clockSR(); // clock SRCLK
}
PORTAbits.RA4 = 1; // clock REGCLK
PORTAbits.RA4 = 0;
}
initS2P();
int bitArray[8];
bitArray[0] = 0;
bitArray[1] = 1;
bitArray[2] = 0;
bitArray[3] = 1;
bitArray[4] = 0;
bitArray[5] = 1;
bitArray[6] = 0;
bitArray[7] = 0;
updateLEDArray(bitArray);
But, for some reason, none of it is working? I can manually switch the pins. Commands like:
PORTAbits.RA2 = 0;
PORTAbits.RA2 = 1;
would leave RA2 high.
Additionally, I can copy and paste those lines hundreds of times and it works.
Oddly, though, when I simplify it into functions, it stops working.
For some reason, when I de-abstract the code and make it one long main, it then stops working again.
Any ideas?