aimiaisyah
Newbie level 3
hi...i am newbie here...
i want to ask about my problem displaying my result in both 1st and second line....but the answer only appear on the 1st line only..
this was taken from some website that use 18f4550, but im trying to modify to use 18f452...im using proteus to simulate this project..
the SetDDRam code is (0x80)
when i set my first and second data adress : (0x00) and (0x40) the result appear like this:
**broken link removed**
when i set my first and second data adress : (0x00) and (0x80) the result appear like this:
**broken link removed**
i want to ask about my problem displaying my result in both 1st and second line....but the answer only appear on the 1st line only..
this was taken from some website that use 18f4550, but im trying to modify to use 18f452...im using proteus to simulate this project..
Code:
#include <p18f452.h>
#include <adc.h>
#include <stdlib.h>
#include <delays.h>
#include "bootlcd.h"
#pragma config WDT = OFF
#pragma config OSC = XT
void low_isr(void);
void high_isr(void);
#pragma code low_vector=0x2018
void interrupt_at_low_vector(void)
{
_asm GOTO low_isr _endasm
}
#pragma code
#pragma code high_vector=0x2008
void interrupt_at_high_vector(void)
{
_asm GOTO high_isr _endasm
}
#pragma code
#pragma interruptlow low_isr
void low_isr (void)
{
return;
}
#pragma interrupt high_isr
void high_isr (void)
{
return;
}
void DelayFor18TCY( void )
{
Delay10TCYx(2); // 5us delay
return;
}
void DelayPORXLCD (void)
{
Delay1KTCYx(75); // Delay of 15ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (15ms * 20MHz) / 4
// Cycles = 75,000
return;
}
void DelayXLCD (void)
{
Delay1KTCYx(25); // Delay of 5ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (5ms * 20MHz) / 4
// Cycles = 25,000
return;
}
void display_lcd (unsigned int intval)
{
unsigned int volt;
char out[10];
volt = intval / 131 ;
while(BusyXLCD());
SetDDRamAddr(0x00);
putrsXLCD("RAW : ");
ltoa(intval, out);
putsXLCD(out);
putrsXLCD(" ");
while(BusyXLCD());
SetDDRamAddr(0x40);
putrsXLCD("Volt : ");
itoa(volt, out);
while(BusyXLCD());
if(volt>99)
{
WriteDataXLCD(out[0]);
while(BusyXLCD());
WriteDataXLCD('.');
while(BusyXLCD());
WriteDataXLCD(out[1]);
while(BusyXLCD());
WriteDataXLCD(out[2]);
}
else if(volt>9)
{
WriteDataXLCD('0');
while(BusyXLCD());
WriteDataXLCD('.');
while(BusyXLCD());
WriteDataXLCD(out[0]);
while(BusyXLCD());
WriteDataXLCD(out[1]);
}
else
{
WriteDataXLCD('0');
while(BusyXLCD());
WriteDataXLCD('.');
while(BusyXLCD());
WriteDataXLCD('0');
while(BusyXLCD());
WriteDataXLCD(out[0]);
}
putrsXLCD("V ");
}
void main( void )
{
char temdata;
unsigned int current_ad_value;
TRISAbits.TRISA0 = 1;
ADCON0bits.ADCS0 = 1; // FOSC/32 clock select , left alignment
ADCON0bits.ADCS1 = 1;
ADCON1bits.ADCS2 = 1;
ADCON1bits.ADFM = 0;
ADCON1 = 0b00000000; // interal ref
ADCON0bits.ADON = 1; // Turn on the ADC
OpenXLCD(); // configure external LCD
while(1)
{
Delay100TCYx (2); // Give the ADC time to get ready.
ADCON0bits.GO = 1; // start the ADC conversion
while (ADCON0bits.GO);
current_ad_value = ADRES;
display_lcd(current_ad_value);
Delay10KTCYx (200);
}
}
the SetDDRam code is (0x80)
when i set my first and second data adress : (0x00) and (0x40) the result appear like this:
**broken link removed**
when i set my first and second data adress : (0x00) and (0x80) the result appear like this:
**broken link removed**
Last edited by a moderator: