smartel99

Port série dallas

May 25th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////
  2. // Fonction : void vInitPortSerie(void)                 Par : Pierre Chouinard
  3. // Compilateur : Keil uVision3 V3.60                    Date: 17 Decembre 2008
  4. //
  5. // Description:  Met les valeurs necessaires dans les SFRs pour configurer
  6. //               le port serie a 57600 bauds avec interruption.
  7. //
  8. // Appel de la fonction : vInitPortSerie();
  9. //////////////////////////////////////////////////////////////////////////////
  10.  
  11. void vInitPortSerie(void)
  12. {
  13.  SCON0 = 0x50;        // Selectione mode 1, 8-bit avec reception
  14.  TMOD  = TMOD | 0x20; // timer 1, mode 2, 8-bit auto reload
  15.  TH1   = 0xFF;        // a 11.0592MHz: FA=4800,FD=9600,FE=14400 et FF=28800
  16.  PCON  = PCON | 0x80; // Le bit SMOD = 1 pour vitesse * 2 du port serie
  17.  
  18.  ET1  = 0;            // Pas interrupt on Timer 1  (IE.3)
  19.  TR1  = 1;            // Active le timer 1
  20.  
  21.  TI_0 = 0;            // Transmit Flag. A 0 pour ne pas generer Int. (SCON0.1)
  22.  RI_0 = 1;            // Receive Flag. Mis a 1 pour generer Int. (SCON0.0)
  23.  ES0  = 1;            // Active l'interruption du port serie  (IE.4)
  24.  
  25. }// Fin vInitPortSerie()
Advertisement
Add Comment
Please, Sign In to add comment