Greetings to all.
I hope to write in the right place .....
I'm doing a project home automation with a PIC18F4520 and LCD.
Unfortunately I have to handle many words and many characters.
To conserve storage space, I thought I'd take advantage of the internal EEPROM.
But how do I convert the value in bytes (EEprom_read) in text ready to be sent to the LCD module? Unfortunately with the conversions present you can only display the value in hex or decimal.
Thank you very much who is willing to devote two minutes to help me.
Greetings.
Christian
Conversion byte to string for LCD
Conversion byte to string for LCD
Greetings.
Christian
Christian
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: Conversion byte to string for LCD
Hi Christian and welcome to the MikroE forum,
Please see Conversion Library:
Conversions Library
http://www.mikroe.com/download/eng/docu ... &width=970
Best regards,
Peter
Please see Conversion Library:
Conversions Library
http://www.mikroe.com/download/eng/docu ... &width=970
Best regards,
Peter
Re: Conversion byte to string for LCD
Hi Peter, thanks for the welcome.petar.timotijevic wrote:Hi Christian and welcome to the MikroE forum,
Please see Conversion Library:
Conversions Library
http://www.mikroe.com/download/eng/docu ... &width=970
Best regards,
Peter
The problem I have is this.
I open eeprom editor and write the text in string format; example my name: Christian.
Now I take the data in bytes in the cells and convert the string to send to an LCD module through the function LCD_Out (1.1, txt)
The problem is that with the conversions present in mikrobasik I can read only the display formats Hex or decimal. C = 0x43 or 67 dec.
I need to see the printed letter "C"
How can I do? is it possible?
thank you very much for the help and availability.
Greetings.
Christian
Christian
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: Conversion byte to string for LCD
Hi,
Also please see Lcd_Chr.
Do you need example?
Simple example in mikroBasic Pro:
Simple example in MikroC Pro:
Code can be further optimized.
Best regards,
Peter
Also please see Lcd_Chr.
Do you need example?
Simple example in mikroBasic Pro:
Code: Select all
'
'
' ASCII HEX
' ===========
' C 43
' h 68
' r 72
' i 69
' s 73
' t 74
' i 69
' a 61
' n 6E
'
' Bytes: 0x43,0x68,0x72,0x69,0x73,0x74,0x69,0x61,0x6E
'
'
program Lcd
' Lcd module connections
dim LCD_RS as sbit at LATB4_bit
LCD_EN as sbit at LATB5_bit
LCD_D4 as sbit at LATB0_bit
LCD_D5 as sbit at LATB1_bit
LCD_D6 as sbit at LATB2_bit
LCD_D7 as sbit at LATB3_bit
dim LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
' End Lcd module connections
dim chval as char
main:
Lcd_Init() ' Initialize Lcd
Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor Off
' EEPROM Write
EEPROM_Write(0x00, 0x43) ' (Writes 'C' to memory address 0x00
EEPROM_Write(0x01, 0x68) ' (Writes 'h' to memory address 0x01
EEPROM_Write(0x02, 0x72) ' (Writes 'r' to memory address 0x02
EEPROM_Write(0x03, 0x69) ' (Writes 'i' to memory address 0x03
EEPROM_Write(0x04, 0x73) ' (Writes 's' to memory address 0x04
EEPROM_Write(0x05, 0x74) ' (Writes 't' to memory address 0x05
EEPROM_Write(0x06, 0x69) ' (Writes 'i' to memory address 0x06
EEPROM_Write(0x07, 0x61) ' (Writes 'a' to memory address 0x07
EEPROM_Write(0x08, 0x6E) ' (Writes 'n' to memory address 0x08
Delay_ms(20) ' Minimum 20ms must be between write and read process
' EEPROM Read
chval = EEProm_Read(0x00) ' Read EEPROM address of 0x00
Lcd_chr(2,1,chval)
chval = EEProm_Read(0x01) ' Read EEPROM address of 0x01
Lcd_chr(2,2,chval)
chval = EEProm_Read(0x02) ' Read EEPROM address of 0x02
Lcd_chr(2,3,chval)
chval = EEProm_Read(0x03) ' Read EEPROM address of 0x03
Lcd_chr(2,4,chval)
chval = EEProm_Read(0x04) ' Read EEPROM address of 0x04
Lcd_chr(2,5,chval)
chval = EEProm_Read(0x05) ' Read EEPROM address of 0x05
Lcd_chr(2,6,chval)
chval = EEProm_Read(0x06) ' Read EEPROM address of 0x06
Lcd_chr(2,7,chval)
chval = EEProm_Read(0x07) ' Read EEPROM address of 0x07
Lcd_chr(2,8,chval)
chval = EEProm_Read(0x08) ' Read EEPROM address of 0x08
Lcd_chr(2,9,chval)
end.
Code: Select all
/*
ASCII HEX
===========
C 43
h 68
r 72
i 69
s 73
t 74
i 69
a 61
n 6E
Bytes: 0x43,0x68,0x72,0x69,0x73,0x74,0x69,0x61,0x6E
*/
char chval;
// Lcd module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End Lcd module connections
void main()
{
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor Off
// EEPROM Write
EEPROM_Write(0x00, 0x43); // (Writes 'C' to memory address 0x00
EEPROM_Write(0x01, 0x68); // (Writes 'h' to memory address 0x01
EEPROM_Write(0x02, 0x72); // (Writes 'r' to memory address 0x02
EEPROM_Write(0x03, 0x69); // (Writes 'i' to memory address 0x03
EEPROM_Write(0x04, 0x73); // (Writes 's' to memory address 0x04
EEPROM_Write(0x05, 0x74); // (Writes 't' to memory address 0x05
EEPROM_Write(0x06, 0x69); // (Writes 'i' to memory address 0x06
EEPROM_Write(0x07, 0x61); // (Writes 'a' to memory address 0x07
EEPROM_Write(0x08, 0x6E); // (Writes 'n' to memory address 0x08
Delay_ms(20); // Minimum 20ms must be between write and read process
// EEPROM Read
chval = EEProm_Read(0x00); // Read EEPROM address of 0x00
Lcd_chr(2,1,chval);
chval = EEProm_Read(0x01); // Read EEPROM address of 0x01
Lcd_chr(2,2,chval);
chval = EEProm_Read(0x02); // Read EEPROM address of 0x02
Lcd_chr(2,3,chval);
chval = EEProm_Read(0x03); // Read EEPROM address of 0x03
Lcd_chr(2,4,chval);
chval = EEProm_Read(0x04); // Read EEPROM address of 0x04
Lcd_chr(2,5,chval);
chval = EEProm_Read(0x05); // Read EEPROM address of 0x05
Lcd_chr(2,6,chval);
chval = EEProm_Read(0x06); // Read EEPROM address of 0x06
Lcd_chr(2,7,chval);
chval = EEProm_Read(0x07); // Read EEPROM address of 0x07
Lcd_chr(2,8,chval);
chval = EEProm_Read(0x08); // Read EEPROM address of 0x08
Lcd_chr(2,9,chval);
}
Best regards,
Peter
- Attachments
-
- LCDResult.jpg (8.37 KiB) Viewed 4590 times
-
- EEPROM.jpg (150.46 KiB) Viewed 4590 times
Re: Conversion byte to string for LCD
Hi Peter,
It 'really very simple and do not know what I was wrong.
Thank you very much for your availability and for the help.
greetings.
It 'really very simple and do not know what I was wrong.
Thank you very much for your availability and for the help.
greetings.
Greetings.
Christian
Christian
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: Conversion byte to string for LCD
Hi,
Best regards,
Peter
I'm glad to see that the problem is solved.Harris74 wrote:Hi Peter,
It 'really very simple and do not know what I was wrong.
Thank you very much for your availability and for the help.
greetings.
Best regards,
Peter