Révision 790
Ajouté par jcguifodjo il y a presque 4 ans
branch/GUIFO/sp4c12/TPC/TPC/TPC.c | ||
---|---|---|
/* This file is generated by Renesas Project Generator (Ver.4.18). */
|
||
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||
/***********************************************************************/
|
||
#include "sfr32c87.h"
|
||
#include "sfr32c87.h"
|
||
|
||
|
||
void uart0_init(void)
|
||
{
|
||
pd6 = 0xFB;
|
||
u0mr = 0x75;
|
||
u0c0 = 0xd0;
|
||
u0brg = 255;
|
||
u0c1 = 0x18;
|
||
//Initialisation des ports
|
||
//CTS entree
|
||
pd6_0 = 0;
|
||
ps0_0 = 0;
|
||
//RTS sortie
|
||
ps0_0 = 1;
|
||
//CLK Entree
|
||
pd6_1 = 0;
|
||
ps0_1 = 0;
|
||
//entree RX
|
||
pd6_2 = 0;
|
||
ps0_2 = 0;
|
||
// sortie TX
|
||
ps0_3 = 1;
|
||
|
||
//Configuration du registre u0mr
|
||
smd0_u0mr = 1;
|
||
smd1_u0mr = 0;
|
||
smd2_u0mr = 1;
|
||
ckdir_u0mr = 0;
|
||
stps_u0mr = 0;
|
||
prye_u0mr = 0;
|
||
iopol_u0mr = 0;
|
||
|
||
//configuration du rgistre U0SMR
|
||
u0smr = 0x00;
|
||
u0smr2 = 0x00;
|
||
u0smr3 = 0x00;
|
||
u0smr4 = 0x00;
|
||
|
||
|
||
//Configuration du registre u0c0
|
||
clk0_u0c0 = 0;
|
||
clk1_u0c0 = 0;
|
||
crs_u0c0 = 1;
|
||
crd_u0c0 = 1;
|
||
nch_u0c0 = 0;
|
||
ckpol_u0c0 = 0;
|
||
uform_u0c0 0;
|
||
//definition du u0brg
|
||
u0brg = 0xFF;
|
||
|
||
//Configuration du registre u0c1
|
||
te_u0c1 = 0;
|
||
re_u0c1 = 0;
|
||
u0rrm_u0c1 = 0;
|
||
u0lch_u0c1 = 0;
|
||
sclkstpb_u0c1 = 0;
|
||
|
||
//Configuration des registres s0tic et s0ric
|
||
s0tic = 0x00;
|
||
s0ric = 0x00;
|
||
u0c1 = 0x1d;
|
||
|
||
|
||
}
|
||
uart0_tx(char c)
|
||
|
||
void uart0_tx(char c)
|
||
{
|
||
u0c1 = 0x1f;
|
||
pd6_0=0;
|
||
p6_3=1;
|
||
u0c0 = 0xd8;
|
||
s0tic = 0x08;
|
||
crd_u0c0 = 1;
|
||
crs_u0c0 = 0;
|
||
te_u0c1 = 1;
|
||
u0tb = c;
|
||
te_u0c1 = 0;
|
||
}
|
||
char uart0_rx()
|
||
{
|
||
char c;
|
||
crd_u0c0 = 1;
|
||
crs_u0c0 = 0;
|
||
re_u0c1 = 1;
|
||
c= u0rb;
|
||
return c;
|
||
}
|
||
void main(void)
|
||
{
|
||
|
||
char c='A';
|
||
uart0_init();
|
||
while (1){
|
||
uart0_tx(c);
|
||
}
|
||
}
|
||
/*void main(void)
|
||
{
|
||
char alpha;
|
||
uart0_init();
|
||
while (1){
|
||
for(alpha = 'A' ; alpha <= 'Z' ; alpha++)
|
||
{
|
||
uart0_tx(alpha);
|
||
}
|
||
}
|
||
}*/
|
Formats disponibles : Unified diff
écriture des fonctions uart0_tx et uart0_rx