Is there anything wrong with my LCD code?

This is a discussion on Is there anything wrong with my LCD code? within the C++ Programming forums, part of the General Programming Boards category; Currently i am doing the serial communication between my VB at comm 1 and the PICDEM 2 BOARD..do i just ...

  1. #1
    CSooi
    Join Date
    Oct 2004
    Posts
    5

    Is there anything wrong with my LCD code?

    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?here i submit on the code for you to have a look whether i got miss out anything or not?thanks... i submitted on my code here so hope you can help me to see is there anything wrong or missed out....thanks a lot..

    #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();
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Go read the Announcements and then edit your post and add CODE TAGS. Noone wants to read that as is.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 09:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 05:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 01:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21