Hello
This is my first post and i have searched forums to try and find a suiteable answer but didnt find anything that would help.
I have written some code that is aimed to change decimal to binary, 16bits worth.
Unfortunatly i can not get it working, the code does compile but doesnt seem to be outputting the correct data.
Code:
void dec_bin(unsigned int bigdata) //function passed decimal number les than 65k
{
while(num>0)
{
rem[j]=num%2; //modulus of 2 to see if there is remainder
num=num/2; //divide number by 2 each time
j++; //increment number of positions
length++; //count length of data
}
for(j=length-1; j>=0; j--)
{
mask=0b1000000000000000;
if((&rem[j])!=0) {dec=dec^mask;} //XOR each time with mask if modulus =1
mask=mask>>1; //right shift mask each time
seperate_data(bigdata); //send random 16bit data to be split into 2 bytes, this function has been tested and works OK
}
}