error in lcd interfacing with pic using c in proteus

Discussion in 'Embedded Systems and Microcontrollers' started by gobi615, Feb 13, 2012.

  1. gobi615

    Thread Starter Member

    Jul 26, 2011
    30
    0
    hi this is my c code to interface pic with lcd . i build it sucessfully in MPLAB HI-TECH C Compiler , when i attached to pic it says error as"internal exception:access violation in module pic16.DLL i didnt find what is problem ..
    i am using pic 16f877a , LM016L(16,2) LCD ..
    Code ( (Unknown Language)):
    1. #include  <pic.h>
    2. //#include  <htc.h>
    3. #define RS RE0
    4. #define RW RE1
    5. #define E RE2
    6. void picinit(void);
    7. void lcdinit(void);
    8. void senddata(char*);
    9. void command(char);
    10. void delay(int);
    11. void main()
    12. {  
    13.     char name[5]="gobi";
    14.     int n=0;
    15.     picinit();
    16.     lcdinit();
    17.     while(1)
    18.     {
    19.       for(n;n!='\0';n++)
    20.       senddata(name);
    21.     }
    22.    
    23. }
    24. void lcdinit()
    25. {
    26.     command(0x38);
    27.     command(0x0f);
    28.     command(0x01);
    29.     command(0x06);
    30.    
    31. }
    32. void command(char comm)
    33. {
    34.    PORTD=comm;
    35.    RS=0;
    36.    RW=0;
    37.    E=1;
    38.    delay(1000);
    39.    E=0;
    40. }
    41. void picinit()
    42. {
    43.   TRISE=0x00;
    44.   PORTE=0x00;
    45.   TRISD=0x00;
    46.   PORTD=0x00;
    47.  
    48. }
    49. void senddata (char *data)
    50. {
    51.   PORTD=*data;
    52.   RS=1;
    53.   RW=0;
    54.   E=1;
    55.   delay(1000);
    56.   E=0;
    57. }
    58. void delay(int d)
    59. {
    60.   int i;
    61.   for(i=0;i<=d;i++);
    62. }
    63.  
     
Loading...