LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Cannot write a int8 on a LCD from a PIC18F4550 using CCSC compiler (https://www.linuxquestions.org/questions/programming-9/cannot-write-a-int8-on-a-lcd-from-a-pic18f4550-using-ccsc-compiler-922031/)

jeanCarloMachado 01-04-2012 11:51 AM

Cannot write a int8 on a LCD from a PIC18F4550 using CCSC compiler
 
Hello all.

I'm writing a program in C that shows the data that comes from computer on a LCD, but all int (or variant) that I print on the LCD from a int variable or pointer shows wrong characters. If i send the data as a string "myString12345" it works.

This is the relevant part of my code:

variables:

unsigned char in_data[50];
unsigned char *p1;
int8 i,e;

code:

while (1){

usb_task();
if (usb_enumerated()){

//output_low(PIN_B7);

if (usb_kbhit(1)){
e=0;
usb_get_packet(1, in_data, 50);
//output_high(PIN_B6);
p1 = &in_data[0];

delay_ms(3000);
for(i=0;i<strlen(in_data);i++){
if(in_data[i]!='\0'){
lcd_gotoxy(1,1);
lcd_putc('\f');
lcd_gotoxy(1,1);
lcd_putc("Dado: ");
lcd_gotoxy(7,1);
lcd_putc(*p1);
lcd_gotoxy(1,2);
lcd_putc("Nro: ");
lcd_gotoxy(6,2);
lcd_putc(i);
toBraille(p1++,PIN_A1);
delay_ms(4000);
lcd_putc('\f');;
delay_ms(1000);
clear();
}
}

lcd_gotoxy(1,1);
lcd_putc('\f');
lcd_gotoxy(1,1);
lcd_putc("Fim!");
delay_ms(3000);
}
//output_low(PIN_B6);
}
//output_low(PIN_B7);
}
}


And another doubt, in some times i have to pick BINARY data from PC and transform it in the correspondent int, none knows how to do this?


Since now tanks.

shuuhen 01-05-2012 09:28 PM

Please add code tags around your code to make it readable.

Most likely, you need to look at converting the int value to the corresponding ASCII character.

theNbomr 01-06-2012 09:46 AM

Integers tend to be larger than 8-bits, and text displays tend to display 8-bit character data. No one can tell what native data type an int8 is without your compiler's or application header file(s) that define that data type. Perhaps simply use data type char or unsigned char to write to your LCD.
Transforming binary data to ASCII (if that's what you mean) is simple with the printf() family of C functions.

That's a lot of unformatted source code....

--- rod.


All times are GMT -5. The time now is 04:10 PM.