Révision 755
Ajouté par gasacco il y a presque 4 ans
branch/sacco/sp4c12/SP4c1/SP4c1/uart0.c | ||
---|---|---|
/***********************************************************************/
|
||
/* */
|
||
/* FILE :uart0.c */
|
||
/* FILE :uart0.c */
|
||
/* DATE :Wed, Jun 02, 2021 */
|
||
/* DESCRIPTION :main program file. */
|
||
/* CPU GROUP :87B */
|
||
... | ... | |
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||
/***********************************************************************/
|
||
|
||
#include "sfr32c87.h"
|
||
|
||
|
||
void uart0_init(void)
|
||
{
|
||
U0MR = 0;
|
||
u0mr = 0x05;
|
||
|
||
//Param?trage des modes sp?ciaux
|
||
u0smr = 0x00;
|
||
u0smr2 = 0x00;
|
||
u0smr3 = 0x00;
|
||
u0smr4 = 0x00;
|
||
|
||
u0c0 = 0x11;
|
||
|
||
//Param?trage des bauds
|
||
u0brg = 32;
|
||
|
||
u0c1 = 0x00;
|
||
pd6_0 =1;
|
||
pd6_1 =0;
|
||
pd6_2 =0;
|
||
pd6_3 =1;
|
||
|
||
ps0_0 =1;
|
||
ps0_1 =0;
|
||
ps0_2 =0;
|
||
ps0_3 =1;
|
||
|
||
u0c1 = 0x05;
|
||
|
||
}
|
||
|
||
void uart0_tx (char c)
|
||
{
|
||
while ( ti_u0c1 !=1);
|
||
|
||
u0tb = c;
|
||
|
||
}
|
||
|
||
char uart0_rx()
|
||
{
|
||
while (ri_u0c1 !=1);
|
||
return u0rb;
|
||
|
||
}
|
||
|
||
|
||
char alphabet(void)
|
||
{
|
||
int c = 65;
|
||
uart0_init();
|
||
|
||
while(1)
|
||
{
|
||
uart0_tx((char) c);
|
||
c = (int)c +1;
|
||
if (c==91)
|
||
{
|
||
c = (int) 65;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void main(void)
|
||
{
|
||
uart0_init();
|
||
while(1)
|
||
{
|
||
uart0_tx(uart0_rx() +1);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Formats disponibles : Unified diff
Codage de uart0_rx, à corriger (freeze du terminal)