LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-04-2012, 11:51 AM   #1
jeanCarloMachado
LQ Newbie
 
Registered: Jul 2011
Location: Carlos Barbosa Brazil
Distribution: CentOS
Posts: 19

Rep: Reputation: 0
Exclamation 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.
 
Old 01-05-2012, 09:28 PM   #2
shuuhen
Member
 
Registered: Jun 2004
Distribution: Mac OS X 10.6.6, Gentoo Linux, FreeBSD 6.0
Posts: 127

Rep: Reputation: 20
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.
 
Old 01-06-2012, 09:46 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LibUSB on PIC18F4550 jeanCarloMachado Linux - Newbie 2 10-27-2011 01:56 AM
read/write,write/write lock with smbclient fails swatidas11 Linux - Networking 1 03-10-2010 12:27 PM
Modeline for my LCD, please take a look - don't want to kill my LCD... brjoon1021 Linux - Hardware 3 12-01-2006 03:21 PM
How to write vga card driver and lcd driver? bobby1112 Programming 2 09-29-2006 05:20 PM


All times are GMT -5. The time now is 02:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration