Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include "C8051F020.h"
  2. #include "c8051F020_SFR16.h"
  3. #include "FO_M1__Structures_COMMANDES_INFORMATIONS_CentraleDeCommande.h"
  4. int i=0;
  5. char chaines[20];
  6.  
  7. //22.184 MHz
  8. void Oscillator_Init_Osc_Quartz()
  9. {
  10. int i = 0;
  11. OSCXCN = 0x67; // Config de l'horloge externe - Quartz > 6,7 MHz
  12. for (i = 0; i < 3000; i++); // attente stabilisation Fosc quartz
  13. while ((OSCXCN & 0x80) == 0); // validation stabilité du quartz
  14. OSCICN = 0x0C; // Commutation sur oscillateur externe
  15. // L'oscillateur n'est pas stopp
  16. }
  17. //
  18.  
  19. //
  20. void Config_Interrupt(){
  21. EA=1;
  22. ES0=1;
  23. }
  24. //
  25.  
  26.  
  27. //
  28. void Config_UART0()
  29. {
  30. TR1=0;
  31. XBR0 |=0x04;
  32. XBR2 |=0x40;
  33. CKCON |= 0x10; //T1M =1
  34. TMOD |= 0x20; //Timer 1 auto reload 8 bit
  35. SM00=0;
  36. SM10=1;
  37. SM20=0;
  38. REN0=1;
  39. PCON &= ~(0x40); // SSTAT0 = '0'
  40. PCON |= 0x80; // SMOD0 = '1' : disables the divide-by-two function of the UART0 baud rate
  41. TCLK0=0; //Transmit Clock Flag for UART0. 0 car on utilise Timer 1
  42. RCLK0=0; //Receive Clock Flag for UART0.
  43. TH1=0xB8;
  44. TR1=1;
  45. RI0=0;
  46. TI0=0;
  47. }
  48. //
  49.  
  50. //
  51. void Decodage() interrupt 4 {
  52.  
  53. char c;
  54. chaine
  55. c=SBUF0;
  56.  
  57. RI0=0;
  58.  
  59.  
  60. }
  61. //
  62.  
  63.  
  64.  
  65. //
  66. void main (void) {
  67.  
  68. COMMANDES chaine;
  69. Oscillator_Init_Osc_Quartz();
  70. Config_interrupt();
  71. Config_UART0();
  72.  
  73.  
  74.  
  75. }
  76. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement