ooicheesan
Junior Member level 1
xlcd.h
Currently i am doing the serial communication between my VB at comm 1 and the PICDEM 2 BOARD..do i just wonder why i cant send my data to light up the LCD at my board?using the MPLAB ICD2?here i submit on the cod efor you to have a look whether i got miss out anything or not?thanks...
#include <p18f452.h>
#include <xlcd.h>
#include <delays.h>
#include <usart.h>
char Data[2];
void Initialise_Serial_Port_Pin(void)
{
// Serial TX & Rx pins configuration.
// TX - port C pin 6
TRISCbits.TRISC6 = 0;
// Rx - port C pin 7
TRISCbits.TRISC7 = 1;
}
void Process_Information(void)
{
switch (Data[0]) {
case 'A':
PORTA = Data[1];
break;
case 'B':
PORTB = Data[1];
break;
case 'C':
PORTC = Data[1];
break;
default:
putrsUSART("Error!");
return;
};
putrsUSART("Ok");
}
char getcharusart()
{
while (!PIR1bits.RCIF)
continue;
PIR1bits.RCIF = 0;
return RCREG;
}
void DelayFor18TCY( void )
{
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
}
void DelayPORXLCD( void )
{
Delay1KTCYx(60); //Delay of 15ms
return;
}
void DelayXLCD( void )
{
Delay1KTCYx(20); //Delay of 5ms
return;
}
void main()
{
unsigned char count = 0;
char temp;
// Serial TX & Rx pins configuration.
Initialise_Serial_Port_Pin();
// configure external LCD
OpenXLCD( EIGHT_BIT & LINES_5X7 );
// configure USART
OpenUSART( USART_TX_INT_OFF &
USART_RX_INT_OFF & //usart configuration
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,25 );
while(1)
{
temp = getcharusart();
Data[count++] = temp;
if (count == 2)
{
Process_Information();
putsXLCD(temp);
count = 0;
}
}
{
CloseUSART();
}
}
Currently i am doing the serial communication between my VB at comm 1 and the PICDEM 2 BOARD..do i just wonder why i cant send my data to light up the LCD at my board?using the MPLAB ICD2?here i submit on the cod efor you to have a look whether i got miss out anything or not?thanks...
#include <p18f452.h>
#include <xlcd.h>
#include <delays.h>
#include <usart.h>
char Data[2];
void Initialise_Serial_Port_Pin(void)
{
// Serial TX & Rx pins configuration.
// TX - port C pin 6
TRISCbits.TRISC6 = 0;
// Rx - port C pin 7
TRISCbits.TRISC7 = 1;
}
void Process_Information(void)
{
switch (Data[0]) {
case 'A':
PORTA = Data[1];
break;
case 'B':
PORTB = Data[1];
break;
case 'C':
PORTC = Data[1];
break;
default:
putrsUSART("Error!");
return;
};
putrsUSART("Ok");
}
char getcharusart()
{
while (!PIR1bits.RCIF)
continue;
PIR1bits.RCIF = 0;
return RCREG;
}
void DelayFor18TCY( void )
{
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
}
void DelayPORXLCD( void )
{
Delay1KTCYx(60); //Delay of 15ms
return;
}
void DelayXLCD( void )
{
Delay1KTCYx(20); //Delay of 5ms
return;
}
void main()
{
unsigned char count = 0;
char temp;
// Serial TX & Rx pins configuration.
Initialise_Serial_Port_Pin();
// configure external LCD
OpenXLCD( EIGHT_BIT & LINES_5X7 );
// configure USART
OpenUSART( USART_TX_INT_OFF &
USART_RX_INT_OFF & //usart configuration
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,25 );
while(1)
{
temp = getcharusart();
Data[count++] = temp;
if (count == 2)
{
Process_Information();
putsXLCD(temp);
count = 0;
}
}
{
CloseUSART();
}
}