Boa noite galera!
Estou começando na área de programação em C, e em algumas vezes meus projetos não consigo concluir, meu compilador é o MICROC FOR PIC 6.0, e simulo no PROTEUS 7.0.
Bom estou fazendo um carregador de bateria com display LCD e comunicação RS 232, consegui fazer funcionar a parte LCD, porém não consigo enviar o valor de tensão que recebo no pino A0 e A1 do meu PIC 16f877A ao RS232.
Código fonte.
char uart_rd;
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_direction at trisb2_bit;
sbit LCD_EN_direction at trisb3_bit;
sbit LCD_D4_direction at trisb4_bit;
sbit LCD_D5_direction at trisb5_bit;
sbit LCD_D6_direction at trisb6_bit;
sbit LCD_D7_direction at trisb7_bit;
int LeituraAD = 0;
char txt [16];
void main()
{
ADCON0=0b00000001;
ADCON1=0b11000100;
TRISA0_bit= 1;
TRISA1_bit= 1;
TRISC= 0;
TRISD=0;
PORTC=0;
PORTD=0;
UART1_INIT (9600);
Delay_ms(200); // Wait for UART 1module to stabilize
UART1_Write_TEXT( " conectado " );
UART1_Write (13);
UART1_Write (10);
Delay_ms(500);
LCD_init();
LCD_cmd (_LCD_CLEAR);
LCD_cmd (_LCD_CURSOR_OFF);
LCD_OUT (1,1,"BATERIA 1");
LCD_OUT (2,1,"BATERIA 2");
LCD_OUT (1,15,"V");
LCD_OUT (2,15,"V");
for(;
{
unsigned long valorAd = 0, tensaoAD = 0;
unsigned char txt [6];
valorAD = ADC_Get_Sample (0);
tensaoAD = (valorAD*1500)/1023;
WordToStr (tensaoAD,txt);
txt[0] = (tensaoAD/1000) + 48;
Lcd_Chr (1,11,txt[0]);
Lcd_Chr (1,13,'.');
txt[1] = (tensaoAD/100)% 10 + 48;
Lcd_Chr (1,12,txt[1]);
txt[1] = (tensaoAD/10)% 1 + 48;
Lcd_Chr (1,14,txt[1]);
valorAD = ADC_Get_Sample (1);
tensaoAD = (valorAD*1500)/1023;
WordToStr (tensaoAD,txt);
txt[0] = (tensaoAD/1000) + 48;
Lcd_Chr (2,11,txt[0]);
Lcd_Chr (2,13,'.');
txt[1] = (tensaoAD/100)% 10 + 48;
Lcd_Chr (2,12,txt[1]);
txt[1] = (tensaoAD/10)% 1 + 48;
Lcd_Chr (2,14,txt[1]);
}
}
Alguém consegue me ajudar?
Desde já agradeço.