yes I know my code is pretty sloppy...I haven't being doing it for very long so I kind of make it up with logic as Im not too sure on the language...but im getting there, slowly. I don't think I can use your code as most of the firmware is contained within a function, and I don't particully want to play around with it too much until I know what I'm doing...
I was wondering if I could ask you for some help tho, i'm playing with a pic USB interface tutorial, where an unsigned char is written to the firmware form a c++ application.
void ProcessIO(void)
{
if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;
if(!HIDRxHandleBusy(USBOutHandle))
{
switch(RecievedDataBuffer[0])
{
case.............
}
USBOutHandle = HIDRxPacket(HID_EP,(BYTE*)&ReceivedDataBuffer,64);
}
}
The problem is its full of switch statements and I would just like to assign j (in my original question) to the imported unsigned char. Although pretty crappy, my original code does the job, but when i try to replace the switch statement with
j = RecievedDataBuffer[0];
upper_nibble = j & 0x0f0 etc..(as in the original question).
The application crashes...Do you have any suggestion of how I could fix this?
Cheers
Martyn