fork(1) download
  1. #include <reg52.h>
  2. sbit P10 = P1 ^ 0;
  3. sbit P32 = P3 ^ 2;
  4. char n = 0;
  5. void main( void ) {
  6. TMOD = 0x00; //設計時器0為模式0;
  7. EA = 1; //
  8. EX0 = 1; //允許P3.2中斷
  9. IT0 = 1; //設P3.2為負緣觸發
  10. ET0 = 0; //關閉計時器中斷
  11. TR0 = 0; //停止計時
  12. while ( 1 )
  13. ;
  14. }
  15. //-------------------------------------------------------------------------
  16. //
  17. //-------------------------------------------------------------------------
  18. void ISR_Key( void )interrupt 0 {
  19. TH0 = ( 8192-104 ) / 32; //鮑率設定
  20. TL0 = ( 8192-104 ) % 32;
  21. EX0 = 0; //關閉P3.2中斷
  22. ET0 = 1; //開啟計時器中斷
  23. TR0 = 1; //開始計時
  24. }
  25. //-------------------------------------------------------------------------
  26. //
  27. //-------------------------------------------------------------------------
  28. void Timer0_isr( void )interrupt 1 {
  29. TH0 = ( 8192-208 ) / 32;
  30. TL0 = ( 8192-208 ) % 32;
  31. P10 = P32;
  32. n ++;
  33. //若接收/傳送10bit後則等待下次的 start bit 觸發P3.2
  34. if ( n == 10 ) {
  35. EX0 = 1; //允許P3.2中斷
  36. ET0 = 0; //關閉計時器中斷
  37. TR0 = 0; //停止計時
  38. n = 0;
  39. }
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:19: fatal error: reg52.h: No such file or directory
compilation terminated.
stdout
Standard output is empty