Microcontroller › PIC › Convert ‘ unsigned long int ‘ to ‘string’ without using inbuilt function for UART › thanks Sasa.. ur post
thanks Sasa.. ur post provided me a lot of help and i implemented it sucessfully
i had to make certain small changes to get it working .. i really appreciate ur help without it would have been lil difficult understanding further step.
i am posting the code here jus incase someone might need it.
void convert_l2s(unsigned long int data0, unsigned char temp_buffer[8])
{
temp_buffer[0]=(data0/1000000)+0x30;
data0%=1000000;
UART_Write_Byte(temp_buffer[0]);
temp_buffer[1]=(data0/100000)+0x30;
data0%=100000;
UART_Write_Byte(temp_buffer[1]);
temp_buffer[2]=(data0/10000)+0x30;
data0%=10000;
UART_Write_Byte(temp_buffer[2]);
temp_buffer[3]=(data0/1000)+0x30;
data0%=1000;
UART_Write_Byte(temp_buffer[3]);
temp_buffer[4]=(data0/100)+0x30;
data0%=100;
UART_Write_Byte(temp_buffer[4]);
temp_buffer[5]=(data0/10)+0x30;
UART_Write_Byte(temp_buffer[5]);
temp_buffer[6]=(data0%10)+0x30;
UART_Write_Byte(temp_buffer[6]);
temp_buffer[7]=0;
UART_Write_Byte(temp_buffer[7]);
}
i am trying to generalize it using loop for n digits int type!!
do i need to use a similar approach for float data as well???