Projet

Général

Profil

« Précédent | Suivant » 

Révision 812

Ajouté par ahkurklu il y a presque 4 ans

Ajout fonction rx

Voir les différences:

branch/KURKLU/sp4c12/sp4c12/sp4c12/sp4c12.c
#include"sfr32c87.h"
#include <stdlib.h>
void uart0_init(void);
void uart0_tx(char c){
te_u0c1 = 1;
ti_u0c1 = 0;
while(ti_u0c1 == 1){
u0tb = c;
}
while(ti_u0c1 != 1);
u0tb = c;
}
char uart0_rx(void){
while(ri_u0c1 !=1);
return u0rb;
}
void main(void)
{
char c = 'Y';
char c = 'A';
uart0_init();//initialisation
/*
while(1){//Affichage alphabet en boucle
uart0_tx(c);
c=c+1;
if(c > 90){
c = 'A';
}
}
*/
while(1){
uart0_tx(uart0_rx());//On utilise la fonction tx pour ecrire sur le terminal le resultat que renvoie rx
}
}
void uart0_init(void){
//U0MR
smd0_u0mr = 1; //Uart en mode 8bit
smd1_u0mr = 0;
......
ps0_1 = 0;
ps0_2 = 0;
ps0_3 = 1;
while(1){
uart0_tx(c);
c=c+1;
if(c > 90){
c = 'A';
}
}
}
}

Formats disponibles : Unified diff