Good evening forum-
I am looking for guidance in completing an embedded c code for a PIC 16F684 that I have been working on. I am new to c for about a week coming over from pic assembly. Please see my code below for reference. This is just code for converting decimal to hexadecimal. My code performs what I need for a 8 bit integer dec to hex in MPLAB, X but I have the result stored in 2 eight bit variables and want it to be stored as one 8 bit integer in hex.
Could someone please guide me accomplishing this?
Shauna
******************************************************************
Moderator edit: added code tags
I am looking for guidance in completing an embedded c code for a PIC 16F684 that I have been working on. I am new to c for about a week coming over from pic assembly. Please see my code below for reference. This is just code for converting decimal to hexadecimal. My code performs what I need for a 8 bit integer dec to hex in MPLAB, X but I have the result stored in 2 eight bit variables and want it to be stored as one 8 bit integer in hex.
Could someone please guide me accomplishing this?
Shauna
******************************************************************
Code:
#include <xc.h>
#include <pic.h>
int mod, num = 148;
int k = 0, t = 0;
void main()
{
while(num>16)
{
mod = num%16;
num = num/16;
} //elihw
if (num>9)
{
switch(num)
{
case 10:
k='A';
break;
case 11:
k='B';
break;
case 12:
k='C';
break;
case 13:
k='D';
break;
case 14:
k='E';
break;
case 15:
k='F';
break;
default:
NOP();
}//hctiws
}//fi
if (mod>9)
{
switch(mod)
{
case 10:
t='A';
break;
case 11:
t='B';
break;
case 12:
t='C';
break;
case 13:
t='D';
break;
case 14:
t='E';
break;
case 15:
t='F';
break;
default:
NOP();
}//hctiws
}//fi
while(1==1);
}
Last edited by a moderator: