Reputation: 786
I recently started work with a PIC32MX764F128H microcontroller, I'm used to doing things on PIC18 and PIC24.. . AKA using CCS C compiler, So I am curious if anyone knows how to do some really basic C code for a 32bit chip in MPLab X. I just want the code to take the input from An analog pin and put the opposite value in an output pin.
For example if PIN_B0 is input and I have a 3.3v plugged into it (this chip uses 3.3 not 5v) I'd like to read PIN_C0 as 0v, but if PIN_B0 is grounded I'd like PIN_C0 to read a high signal of 3.3v
I'm very rusty at this on such a low level application and cannot remember how to do so in C. Below is some of what I have so far in C but it isn't compiling and MPLab is awful at assisting in code issues.
#fuses HS,NOLVP,NOWDT,PUT
int main()
{
TRISB=0;//all of Port B is input
TRISC=1;//all of Port C is output
int RecvInput;
while(true)
{
RecvInput = ??? //how do I get from Pin_B0 ??
if(Recv==0)
{
//HOW DO I SAY PIN_C0 = HIGH
}
else //PIN_C0 = 0
}
}
Upvotes: 1
Views: 3556
Reputation: 7975
Try this:
RecvInput = mPORTBRead();
Then to output:
mPORTBWrite(value);
Upvotes: 1