Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <msp430.h>
  2.  
  3.  
  4. /**
  5. * main.c
  6. */
  7. int main(void)
  8. {
  9. WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
  10.  
  11. P4SEL |= BIT4 + BIT5; //P4.4 P4.5 appartengono alla UART
  12.  
  13. //configurazione interfaccia seriale
  14. UCA1CTL1 |= UCSWRST; //disabilita UART
  15. UCA1CTL1 |= UCSSEL_2; //seleziona SMLCK
  16.  
  17. //imposta bound rate a 9600 bps
  18. UCA1BR0 = 109; //imposta il prescaler
  19. UCA1BR1 = 0;
  20. UCA1MCTL = UCBRS_2; //imposta il modulatore
  21.  
  22. //nessuna configurazione di carattere
  23. //usiamo conf. di default (8 bit, N, 1 stop bit, LSB first)
  24.  
  25. UCA1CTL1 &= ~UCSWRST; //abilita l'interfaccia
  26.  
  27. while(1){
  28.  
  29. while(!(UCA1IFG & UCTXIFG)); //aspetta finchè non è possibile trasmettere
  30. UCA1TXBUF = 65; //trasmetti 'A'
  31.  
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement