![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| The mplab c30 compiler does not support itoa() function. how do I change a hex number ie 0x55 to become a char '55' without using the printf(). Thanks | |
| |
| | (permalink) |
| There is probably some easier way but this gets the job done, Code: intVal=0x34; charout[0]=(intVal>>4)+0x30; charout[1]=intVal&0x0f+0x30; | |
| |
| | (permalink) |
| Hi Pommie Thanks for your help. but what I need is charout[0] = 55 , not charout[0]=5, charout[1]=5 | |
| |
| | (permalink) |
| Isnt't that just charout=(char)intVal; or even, charout=intVal&0xff; Mike. | |
| |
| | (permalink) |
| I tried that too, but mplab c30 compiler does not work with casting and masking ,so it still does not solve the problem. | |
| |
| | (permalink) | |
| Quote:
Code: #include <p30f2010.h>
unsigned int x;
unsigned char outchar;
int main(void){
x = 0x45;
outchar=(char)x;
x = 0x45;
outchar=x&0xff;
x = 0x45;
outchar=x;
while(1);
} Maybe you should post an example of what doesn't work. Mike. | ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| c++ convert argv[1] to a char array | danielsmusic | Chit-Chat | 5 | 18th March 2006 02:09 PM |
| revew code please | Seb | Micro Controllers | 1 | 22nd February 2005 02:15 PM |
| I2C Master write problem using SSP (here's code) | Oznog | Micro Controllers | 1 | 16th October 2004 06:48 AM |
| HOW TO CONVERT HEXA TO DECIMAL FOR LCD, PLS HELP!!!!!!!! | AUNG THANT | Micro Controllers | 3 | 10th April 2004 01:38 PM |
| PIC 16f84A and PowerTip Alphanumeric display | 27 | Micro Controllers | 1 | 9th March 2004 03:19 PM |