Révision 505
Ajouté par abseck1 il y a presque 4 ans
SP4b2.c | ||
---|---|---|
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||
/***********************************************************************/
|
||
|
||
void main(void)
|
||
#include "sfr32c87.h"
|
||
|
||
#define RS p1_0
|
||
#define RW p1_1
|
||
#define E p1_2
|
||
#define BF p0_7
|
||
|
||
void tempo(void)
|
||
{
|
||
int i;
|
||
for (i=0 ; i<1000 ;i++)
|
||
asm("nop");
|
||
}
|
||
|
||
void init_ports_aff(void)
|
||
{
|
||
pd0 = 0xff;
|
||
p0 = 0x00;
|
||
pd1= 0xff;
|
||
p1=0x00;
|
||
}
|
||
|
||
|
||
|
||
void busy(void)
|
||
{
|
||
pd0=0x00;//entr?e
|
||
RS=0;
|
||
RW=1;
|
||
E=1;
|
||
while(BF!=0);
|
||
E=0;
|
||
pd0=0xff;//sortie
|
||
}
|
||
|
||
void affiche_caractere(unsigned char caractere)
|
||
{
|
||
|
||
RS=1;
|
||
RW=0;
|
||
p0=caractere;
|
||
E=1;
|
||
tempo();
|
||
E=0;
|
||
tempo();
|
||
busy();
|
||
}
|
||
|
||
void affiche_commande(unsigned char commande)
|
||
{
|
||
|
||
RS=0;
|
||
RW=0;
|
||
p0=commande;
|
||
E=1;
|
||
tempo();
|
||
E=0;
|
||
tempo();
|
||
busy();
|
||
}
|
||
|
Formats disponibles : Unified diff
Fin séance b2