We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello dear all, I have a problem in showing hex packet on LCD.I send a hex file by UART and i want to show it on LCD. but LCD show different number. like : i send 02 but it show 202. I taught maybe it's because of baud rate but it isn't work still. could you tell me what's the problem? i use keil and my ARM is LPC1768
#include <LPC17xx.H> definitions #include "LCD.h" #include "string.h" #include "sys.h" #include "lcd.h" #include "touch.h" #include "exti.h" #include <stdio.h> #include "uart.h" unsigned char lcd_buf[50]; unsigned char s[10]; void Delay (uint32_t Time) { uint32_t i; i = 0; while (Time--) { for (i = 0; i < 5000; i++); } } /* ********************************************************************************************************* * Description: The function is setting font colors¡¢brush colors and the area of clear * Arguments : None * Returns : None ********************************************************************************************************* */ void Load_Drow_Dialog(void) { LCD_Clear(WHITE); POINT_COLOR=Red; //Setting font colors LCD_ShowString(216,0,"txt"); //Displaying screen clear area POINT_COLOR=BLUE; //Setting brush color } /* ********************************************************************************************************* * Description: Main function * Arguments : None * Returns : None ********************************************************************************************************* */ int main (void) { int i=0; int j=0; SystemInit(); LCD_Init(); Load_Drow_Dialog(); UART2_Init(); while(1){ for(i=0;i<7;i++){ s[i]=UART2_GetChar()-190; } sprintf(lcd_buf,"%d-%d-%d-%d",s[3],s[4],s[5],s[6]); LCD_ShowString(40,60,lcd_buf ); Delay(4000); } }
You claim you send hexadecimal data.
The only time it would be meaningful to talk about hexadecimal data would be if you send it as ASCII characters '0'..'9', 'A'..'F' (or lower-case 'a'..'f').
But why do you then subtract 190 from every received character?
s[i]=UART2_GetChar()-190;
actually, i tried to check that any of my numbers sum to 190 but it wasn't,it just show random number. i forgot to erase this part. i just write UART2_GetChar().
in addition, LCD and UART in a separate code work correctly, but when use two codes it doesn't work.