ChrisTV
Newbie level 2
- Joined
- Jan 30, 2015
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 23
Hi all
I am struggling to figure out why I am not able to send data to my 16x2 LCD display from my pic16f877a. I am a newbie and still learning, but I tried to compile my program many times, and had noticed that as I approached the flash memory of the pic (hex file size) the LCD behaved differently. I am using Proteus 8 for simulation as well. I have view many forums and examples.
Any help would be much appreciated.
My code is below..
I am struggling to figure out why I am not able to send data to my 16x2 LCD display from my pic16f877a. I am a newbie and still learning, but I tried to compile my program many times, and had noticed that as I approached the flash memory of the pic (hex file size) the LCD behaved differently. I am using Proteus 8 for simulation as well. I have view many forums and examples.
Any help would be much appreciated.
My code is below..
Code dot - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 // LCD module connections sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_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 unsigned int ADCValue; unsigned int pwmValue; char x[4]; char pwm[4]; void main() { UART1_Init(115200); ADC_Init(); PWM1_Init(5000); PORTA=0; PORTB=0; TRISA=0x1; TRISC=0x39; PWM1_Start(); Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off do { // Calculations unsigned int input; unsigned int pwm; ADCValue=ADC_Read(0); pwm=2.55E2*ADCValue/1024; pwmValue=1E2*ADCValue/1024; WordToStr(pwmValue,pwm); WordToStr(ADCValue,x); delay_ms(20); // LCD Display Lcd_Out(1,1,"Analog V:"); Lcd_Out(1,11,x); delay_ms(20); Lcd_Out(2,1,"PWM % :"); Lcd_Out(2,11,pwmValue); PWM1_Set_Duty(pwm); // Serial port UART1_Write_Text("Analog Value="); UART1_Write_Text(x); UART1_Write(13); Delay_ms(20); }while(1); }
Last edited by a moderator: