📄 cpu.lst
字号:
void PowerLED(BYTE flag)
{
#define GREEN_LED P0_4
#define RED_LED P0_5
if( flag==ON ) {
GREEN_LED = 0; // ON GREEN
RED_LED = 0; // ON RED
dPuts("\r\n(PowerLED)-ON");
}
else {
GREEN_LED = 1; // OFF FREEN
RED_LED = 0; // ON RED
dPuts("\r\n(PowerLED)-OFF");
}
C51 COMPILER V7.50 CPU 04/01/2008 15:02:02 PAGE 13
}
#endif
736
737 //------------------------ common routines with interrupts --------------------
738
739 /*****************************************************************************/
740 /* Ext Int 1 Interrupt */
741 /*****************************************************************************/
742 //INTERRUPT(2, ext1_int)
743 void ext1_int(void) interrupt 2 using 1
744 {
745 1 EX1 = 0;
746 1 }
747
748 //****************************************************************************/
749 // Timer 0 Interrupt
750 // If TL0 overflow,
751 // .Invoke this interrupt
752 // .TL0 <- TH0
753 // TL0 is incremented every machine cycle
754 // Every machine cycle is 12*Tosc(11.0592MHz)
755 //
756 // Every machine cycle = 1.085us
757 // Interrupt interval = 208us ( 1.085*(256-64(TH0)) )
758 // When tm001==48, it's 0.01sec. 48*208us
759 //
760 //****************************************************************************/
761
762 #ifndef INTERNAL_MCU
#define _ReadKey() ( ((~P4>>2)& 0x01) | (~P1 & 0xfc) )
#endif
765
766 //=============================================================================
767 // Remocon
768 //=============================================================================
769
770 #ifdef REMO_RC5
771
772 void InitForRemo(void)
773 {
774 1 WORD temp;
775 1
776 1 #if defined CLOCK_11M
#ifdef TECHWELL_REMOCON // DONGYANG
temp = 0x10000 - 193; // 209.62us = 1.085*193
#else
temp = 0x10000 - 204; // 221.34us = 1.085*204
#endif
#elif defined CLOCK_22M
#ifdef TECHWELL_REMOCON // DONGYANG
temp = 0x10000 - 193*2; // 209.62us = 1.085/2*193*2
#else
temp = 0x10000 - 204*2; // 221.34us = 1.085/2*204*2
#endif
#elif defined CLOCK_27M // intenal_mcu
793 1
794 1 #ifdef TECHWELL_REMOCON // DONGYANG
795 1 temp = 0x10000 - 20; // 209.62us = 1/27 * 283 * 20 = 209.63uS
C51 COMPILER V7.50 CPU 04/01/2008 15:02:02 PAGE 14
796 1 T2HIGH = 1; // 283 = 256 + 27
797 1 T2LOW = 27; //
798 1 #else
temp = 0x10000 - 36; // 221.34us = 1/27 * 166 * 36 = 221.33uS
T2HIGH = 0; //
T2LOW = 166; //
#endif
803 1
804 1 #endif
805 1
806 1 RCAP2H = TH2 = temp>>8;
807 1 RCAP2L = TL2 = (BYTE)(temp & 0xff);
808 1 TR2 = 1;
809 1
810 1 tm01 = 4;
811 1 RemoPhase1 = 1;
812 1 RemoSystemCode= RemoDataCode=0;
813 1 }
814
815 #elif defined REMO_NEC
void InitForRemo(void)
{
WORD temp;
#if defined CLOCK_11M
temp = 0x10000 - 173; // 187.71us = 1.085*173
#elif defined CLOCK_22M
temp = 0x10000 - 173*2;
#elif defined CLOCK_27M
T2HIGH = 0; //
T2LOW = 252; //
temp = 0x10000 - 20; // 186.667uS = 1 /27 * 252 * 20
#endif
RCAP2H = TH2 = temp>>8;
RCAP2L = TL2 = (BYTE)(temp & 0xff);
TR2 = 1;
tm01 = 0;
RemoStep = 0;
RemoPhase = 0;
RemoHcnt = 0;
RemoLcnt = 0;
}
#endif
844
845
846 ///****************************************************************************
847 ///* Ext Int 0 Interrupt
848 ///****************************************************************************
849 //_interrupt(0) void remocon_int (void)
850 //INTERRUPT(0, remocon_int)
851 void remocon_int(void) interrupt 0 using 1
852 {
853 1 EX0 = 0; // Enable Remocon (Enable Ext int0)
854 1 InitForRemo();
855 1 }
856
857 //*****************************************************************************
C51 COMPILER V7.50 CPU 04/01/2008 15:02:02 PAGE 15
858 // Serial Interrupt
859 //*****************************************************************************
860 #ifdef SERIAL
861
862 //INTERRUPT(4, serial_int)
863 void serial_int(void) interrupt 4 using 1 // register bank 1
864 {
865 1 if( RI ) { //--- Receive interrupt ----
866 2 RI = 0;
867 2 RS_buf[RS_in++] = SBUF;
868 2 if( RS_in>=BUF_MAX ) RS_in = 0;
869 2 }
870 1
871 1 if( TI ) { //--- Transmit interrupt ----
872 2 TI = 0;
873 2 RS_Xbusy=0;
874 2 }
875 1 }
876 //=============================================================================
877 // Serial RX Check
878 //=============================================================================
879 BYTE RS_ready(void)
880 {
881 1 if( RS_in == RS_out ) return 0;
882 1 else return 1;
883 1 }
884 //=============================================================================
885 // Serial RX
886 //=============================================================================
887 BYTE RS_rx(void)
888 {
889 1 BYTE ret;
890 1
891 1 ES = 0;
892 1 ret = RS_buf[RS_out];
893 1 RS_out++;
894 1 if(RS_out >= BUF_MAX)
895 1 RS_out = 0;
896 1 ES = 1;
897 1
898 1 return ret;
899 1 }
900 //=============================================================================
901 // Serial TX
902 //=============================================================================
903 void RS_tx(BYTE tx_buf)
904 {
905 1 while(RS_Xbusy);
906 1 SBUF = tx_buf;
907 1 RS_Xbusy=1;
908 1 }
909
910 #endif // SERIAL
911
912
913
914 //****************************************************************************/
915 // Timer 2 Interrupt
916 // If TH2 and TL2 are overflowed,
917 // .Invoke this interrupt
918 // .TH2 <- RCAP2H
919 // .TL2 <- RCAP2L
C51 COMPILER V7.50 CPU 04/01/2008 15:02:02 PAGE 16
920 // TL2 is incremented every machine cycle
921 // Every machine cycle is 12*Tosc(11.0592MHz)
922 //
923 // Every machine cycle = 1.085us
924 // Interrupt interval
925 // 1) REMO_RC5
926 // 221.34us ( 1.085*204 ) // (256-52) (0x10000-0xff34)
927 //
928 // data length: 14bit (2sync bits, 1 control bit, 11 data bits) 24,889ms
929 //
930 // +----+
931 // 1 is coded: | |
932 // +----+
933 // T T
934 //
935 // +----+
936 // 0 is coded: | |
937 // +----+
938 // T T T = 889us
939 //
940 // *) DongYang
941 // 209.62 ( 1.085*193 ) // (256-63) (0x10000-0xff3f)
942 //-----------------------------------------------------------------------------
943 // 2) REMO_NEC
944 // 187.714us ( 1.085*173 ) // (256-83) (0x10000-0xff53)
945 //
946 //****************************************************************************/
947 //INTERRUPT(5, timer2_int)
948 void timer2_int(void) interrupt 5 using 1 // using register block 3
949 {
950 1 TF2 = 0; // clear overflow
951 1
952 1 tm01++;
953 1
954 1 #ifdef REMO_RC5
955 1 {
956 2 BYTE i;
957 2
958 2 i = tm01 & 0x07;
959 2 if( i>=1 && i<=2 )
960 2 RemoPhase1 = P3_2;
961 2 else if( i>=5 && i<=6 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -