Dans le cadre d'un project,je dois utiliser un lcd pour afficher un texte selon la donnee envoye.
Le probleme est que une fois cette donne envoye(cette data est envoye par un autre pic via un transmetteur),le Pic marche,mais le LCD ecrit nimporte quoi!
Pourtant cela fonctionne tres bien sur Hyperterminal.Je travaille avec IAR Embedded
Donc auriez vous une solution s'il vous plait
j'utilise un pic16f876 et un lcd 2*16 lignes
je vous laisse mon programme;
#include<io16f876.h> // Prototype
#include"LCDdrive.h"
#pragma vector=0x04 //set a Interrupt vector
__interrupt void my_ISR(void);
void intial_recieve(void);
void intial_transmit(void);
void send_cmd(unsigned char data);
void delay(unsigned char t); //generic delay prototype
unsigned char mymodule[]={"In Living Room"};
unsigned char mymodule1[]={"You'Re Going Out"};
unsigned char mymodule2[]={"Lock The Door"};
unsigned char mymodule3[]={"Everything is OK"};
int i,j,cD,m,sensor=0;
void main(void)
{
intial_transmit(); //Initializing the transmitter
intial_recieve();
RP1=0;
RP0=1;
TRISA=0x00;
OPTION=0x07; //Set prescaler to 256
RP0=0;
RP1=0;
PORTA=0x00;
while(1)
{
if(sensor==0x42)
{
LCD_cursor(0,0); /*move the cursor to the 1st line*/
LCD_puts(mymodule1);
delay(2);
PORTA=0x02;
LCD_initialise();
LCD_cursor(0,1); /*move the cursor to the 1st line*/
LCD_puts(mymodule2);
for (j=0;j<6;j++)
{
PORTA=0x02; // Bip
delay(1);
PORTA=0x00;
delay(1);
}
LCD_clear();
PORTA=0;
sensor=0x00;
}//end if
if (sensor==0x41)
{
PORTA=0x01;
delay(3);
LCD_cursor(0,0); /*move the cursor to the 1st line*/
LCD_puts(mymodule);
LCD_cursor(0,1); /*move the cursor to the 2nd line*/
LCD_puts(mymodule3);
delay(8);
LCD_clear();
PORTA=0;
sensor=0;
}
}//end while
}//end main
void intial_transmit(void)
{
BRGH=1;//TXSAT
SPBRG=175;
SYNC=0; //setting serial transmission to ASYNCRONOUS..
SPEN=1; //ENABLE SERIAL PORT
TXIE=0; //DISABLE INTERUPT
//RCIF=0; //DISABLE RECIEVE INTERUPT
TX9=0; //8-bit transmission
TXEN=1;//set baud rate to high BRGH=1 and TXEN=1
}
void send_cmd(unsigned char data)
{
while(!TXIF) //set when reg is empty
{
}
RCIE=0; //Disabling Reciever Interrupt
TXIF=0; // Disabling Transmission flag
TXREG=data; //writing transmit data to Transmit register
RCIE=1; //Enabling Reciever interrupt
}
void delay(unsigned char t)//generic delay function
{
int i,j;
for(j=0;j<t;j++)
{
for(i=0;i<4;i++)
{
TMR0=0; /*clear TMR0*/
while(TMR0-200); /*wait for a while */
}
}
return; /*return to the calling function */
}
void intial_recieve(void)
{
STATUS=0X20;// access Bank 1
BRGH=1;//TXSAT //set baud rate to high
SPBRG=175;//99H//for 4MHZ Setting baud rate to 9600
SYNC=0; //enable port for asyncronous transmission
STATUS=0X00;// access Bank 0
SPEN=1; //enable port for asyncronous transmission
STATUS=0X20;// access Bank 1
RCIE=1; //Enable interupt.
STATUS=0X00;// access Bank 0
RX9=0; //8-bit reception.
CREN=1; //continuous recieve enable bit.
STATUS=0X20;// access Bank 1
GIE=1; //Enable Global Interrupt
PEIE=1; //Enable perpheral interrupt
}
__interrupt void my_ISR(void)
{
while(!RCIF)
{
}
GIE=0;//Global interrupt Disable
RCIF=0; //Disabing Recieve Flag
sensor=RCREG;
RCIF=0; //disabling flag
GIE=1; //Global interrupt Enable
}
-----