Hey,
I'm new to this forum, but hopefully you guys can help me with some questions.
I'm programming a pic18f4550 microcontroller using MPLAB and the C18 C compiler. Im trying to drive a 4 digit 7-seg display, but this C18 compiler is doing some weird things that i don't understand. The MPLAB SIM simulates the code properly, it's only when i run the program on the chip that i get these strange problems. I'm hoping i forgot to check a little box in some obscure setting option somewhere
here is an example of an issue i'm having:
It only seems to properly output to the PORT pins the unsigned char data type (never had this issue with other compilers such as hi-tech C or AVR compilers)-
int x = 8;
PORTB = x; (doesn't produce proper output on the pins)
unsigned char x = 8;
PORTB = x (correct output)
i figure this is because the char data type is 8 bits (same as the PORTB of this PIC) and the int data type is 16 bits? I'd like to manipulate data using int data type and output that to the port directly rather than using chars, and i've tried type casting and it doesn't work- seems to just ignore the type casting. anyone know why?
I've got other baffling problems that i've never had before using other compilers or other microcontrollers, but i figure i'll start small for now. I'd like to be able to use the C18 compiler though because everyone else seems to use it and think its great. So far, i find the compiler very quirky and unpredictable.
any solutions, clues or hints would be appreciated...
Thanks a lot
Rick
ps again, perhaps it's some MPLAB/C18 setting that i didn't setup properly?
I'm new to this forum, but hopefully you guys can help me with some questions.
I'm programming a pic18f4550 microcontroller using MPLAB and the C18 C compiler. Im trying to drive a 4 digit 7-seg display, but this C18 compiler is doing some weird things that i don't understand. The MPLAB SIM simulates the code properly, it's only when i run the program on the chip that i get these strange problems. I'm hoping i forgot to check a little box in some obscure setting option somewhere
here is an example of an issue i'm having:
It only seems to properly output to the PORT pins the unsigned char data type (never had this issue with other compilers such as hi-tech C or AVR compilers)-
int x = 8;
PORTB = x; (doesn't produce proper output on the pins)
unsigned char x = 8;
PORTB = x (correct output)
i figure this is because the char data type is 8 bits (same as the PORTB of this PIC) and the int data type is 16 bits? I'd like to manipulate data using int data type and output that to the port directly rather than using chars, and i've tried type casting and it doesn't work- seems to just ignore the type casting. anyone know why?
I've got other baffling problems that i've never had before using other compilers or other microcontrollers, but i figure i'll start small for now. I'd like to be able to use the C18 compiler though because everyone else seems to use it and think its great. So far, i find the compiler very quirky and unpredictable.
any solutions, clues or hints would be appreciated...
Thanks a lot
Rick
ps again, perhaps it's some MPLAB/C18 setting that i didn't setup properly?