Hi All,
How to convert a HEX value to DEC value. For example: Var mai = $2B and I want to store the decimal value of this (which is 43 in decimal) in other variable.
On LCD is all ok, shows the right dec value, but how to store this in decimal in other variable that's my problem.
I do some search on the forum but no success. Can me to someone explain how to do?
Thanks.
Code:#CONFIG cfg = _INTRC_OSC_NOCLKOUT cfg&= _WDT_ON cfg&= _PWRTE_OFF cfg&= _MCLRE_OFF cfg&= _CP_OFF cfg&= _CPD_OFF cfg&= _BOD_ON cfg&= _IESO_ON cfg&= _FCMEN_ON __CONFIG cfg #ENDCONFIG DEFINE OSC 8 ; Use a 8 MHZ internal clock OSCCON = %01110000 DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_BAUD 38400 DEFINE HSER_CLROERR 1 ' Clear overflow automatically Define LCD_DREG PORTC Define LCD_DBIT 0 Define LCD_RSREG PORTC define LCD_RSBIT 4 define LCD_EREG PORTC define LCD_EBIT 5 define LCD_BITS 4 define LCD_LINES 2 define LCD_COMMANDUS 2000 define LCD_DATAUS 50 ANSELH = 0 ; Set RB6 (TX) pin to digital ANSEL = 0 ; Set all digital TRISA = %011100 ; Set RA5,RA4,RA3 input ; RA2,RA1,RA0 output TRISB = %0011 ; Set RB4,RB5 input ; RB6,RB7 output TRISC = %00000000 ; Set RC0,RC3,RC4,RC5,RC6, RC1,RC2,RC7 output CM1CON0 = 0 ; Disable comparator 1 CM2CON0 = 0 ; Disable comparator 2 OPTION_REG.7=1 ; Disable weak pull ups mai var byte[2] decvalue var byte Lcdout $fe, 1 pause 1000 main: hserout ["01 05",13,10] pauseus 1 HSerin 1000,main, [wait ("41 05"), skip 1, hex mai] Lcdout $fe, 1 lcdout dec mai let decvalue = mai pause 1000 goto main




Bookmarks