cpu.lst
来自「显示屏驱动源代码」· LST 代码 · 共 1,256 行 · 第 1/5 页
LST
1,256 行
#endif
723 1 Printf("%s \n", PanelInfoStr);
724 1 CheckSpecialMode();
725 1 main_init();
726 1
727 1 }
728 //=============================================================================
729 // Power LED ON / OFF
730 //=============================================================================
731 void PowerLED(BYTE flag)
732 {
733 1 #define GREEN_LED P0_4
C51 COMPILER V7.06 CPU 02/21/2008 14:00:25 PAGE 13
734 1 #define RED_LED P0_5
735 1
736 1 if( flag==ON ) {
737 2 GREEN_LED = 0; // ON GREEN
738 2 RED_LED = 0; // ON RED
739 2 dPuts("\r\n(PowerLED)-ON");
740 2 }
741 1 else {
742 2 GREEN_LED = 1; // OFF FREEN
743 2 RED_LED = 0; // ON RED
744 2 dPuts("\r\n(PowerLED)-OFF");
745 2 }
746 1 }
747 #endif
748
749 //------------------------ common routines with interrupts --------------------
750
751 /*****************************************************************************/
752 /* Ext Int 1 Interrupt */
753 /*****************************************************************************/
754 //INTERRUPT(2, ext1_int)
755 void ext1_int(void) interrupt 2 using 1
756 {
757 1 EX1 = 0;
758 1 }
759
760 //****************************************************************************/
761 // Timer 0 Interrupt
762 // If TL0 overflow,
763 // .Invoke this interrupt
764 // .TL0 <- TH0
765 // TL0 is incremented every machine cycle
766 // Every machine cycle is 12*Tosc(11.0592MHz)
767 //
768 // Every machine cycle = 1.085us
769 // Interrupt interval = 208us ( 1.085*(256-64(TH0)) )
770 // When tm001==48, it's 0.01sec. 48*208us
771 //
772 //****************************************************************************/
773
774 #ifndef INTERNAL_MCU
775 #define _ReadKey() ( ((~P4>>2)& 0x01) | (~P1 & 0xfc) )
776 #endif
777
778 //=============================================================================
779 // Remocon
780 //=============================================================================
781
782 #ifdef REMO_RC5
783
784 void InitForRemo(void)
785 {
786 1 WORD temp;
787 1
788 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
C51 COMPILER V7.06 CPU 02/21/2008 14:00:25 PAGE 14
#elif defined CLOCK_22M
797 1
798 1 #ifdef TECHWELL_REMOCON // DONGYANG
799 1 temp = 0x10000 - 193*2; // 209.62us = 1.085/2*193*2
800 1 #else
temp = 0x10000 - 204*2; // 221.34us = 1.085/2*204*2
#endif
803 1
804 1 #elif defined CLOCK_27M // intenal_mcu
#ifdef TECHWELL_REMOCON // DONGYANG
temp = 0x10000 - 20; // 209.62us = 1/27 * 283 * 20 = 209.63uS
T2HIGH = 1; // 283 = 256 + 27
T2LOW = 27; //
#else
temp = 0x10000 - 36; // 221.34us = 1/27 * 166 * 36 = 221.33uS
T2HIGH = 0; //
T2LOW = 166; //
#endif
#endif
817 1
818 1 RCAP2H = TH2 = temp>>8;
819 1 RCAP2L = TL2 = (BYTE)(temp & 0xff);
820 1 TR2 = 1;
821 1
822 1 tm01 = 4;
823 1 RemoPhase1 = 1;
824 1 RemoSystemCode= RemoDataCode=0;
825 1 }
826
827 #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
856
857
C51 COMPILER V7.06 CPU 02/21/2008 14:00:25 PAGE 15
858 ///****************************************************************************
859 ///* Ext Int 0 Interrupt
860 ///****************************************************************************
861 //_interrupt(0) void remocon_int (void)
862 //INTERRUPT(0, remocon_int)
863 void remocon_int(void) interrupt 0 using 1
864 {
865 1 EX0 = 0; // Enable Remocon (Enable Ext int0)
866 1 InitForRemo();
867 1 }
868
869 //*****************************************************************************
870 // Serial Interrupt
871 //*****************************************************************************
872 #ifdef SERIAL
873
874 //INTERRUPT(4, serial_int)
875 void serial_int(void) interrupt 4 using 1 // register bank 1
876 {
877 1 if( RI ) { //--- Receive interrupt ----
878 2 RI = 0;
879 2 RS_buf[RS_in++] = SBUF;
880 2 if( RS_in>=BUF_MAX ) RS_in = 0;
881 2 }
882 1
883 1 if( TI ) { //--- Transmit interrupt ----
884 2 TI = 0;
885 2 RS_Xbusy=0;
886 2 }
887 1 }
888 //=============================================================================
889 // Serial RX Check
890 //=============================================================================
891 BYTE RS_ready(void)
892 {
893 1 if( RS_in == RS_out ) return 0;
894 1 else return 1;
895 1 }
896 //=============================================================================
897 // Serial RX
898 //=============================================================================
899 BYTE RS_rx(void)
900 {
901 1 BYTE ret;
902 1
903 1 ES = 0;
904 1 ret = RS_buf[RS_out];
905 1 RS_out++;
906 1 if(RS_out >= BUF_MAX)
907 1 RS_out = 0;
908 1 ES = 1;
909 1
910 1 return ret;
911 1 }
912 //=============================================================================
913 // Serial TX
914 //=============================================================================
915 void RS_tx(BYTE tx_buf)
916 {
917 1 while(RS_Xbusy);
918 1 SBUF = tx_buf;
919 1 RS_Xbusy=1;
C51 COMPILER V7.06 CPU 02/21/2008 14:00:25 PAGE 16
920 1 }
921
922 #endif // SERIAL
923
924
925
926 //****************************************************************************/
927 // Timer 2 Interrupt
928 // If TH2 and TL2 are overflowed,
929 // .Invoke this interrupt
930 // .TH2 <- RCAP2H
931 // .TL2 <- RCAP2L
932 // TL2 is incremented every machine cycle
933 // Every machine cycle is 12*Tosc(11.0592MHz)
934 //
935 // Every machine cycle = 1.085us
936 // Interrupt interval
937 // 1) REMO_RC5
938 // 221.34us ( 1.085*204 ) // (256-52) (0x10000-0xff34)
939 //
940 // data length: 14bit (2sync bits, 1 control bit, 11 data bits) 24,889ms
941 //
942 // +----+
943 // 1 is coded: | |
944 // +----+
945 // T T
946 //
947 // +----+
948 // 0 is coded: | |
949 // +----+
950 // T T T = 889us
951 //
952 // *) DongYang
953 // 209.62 ( 1.085*193 ) // (256-63) (0x10000-0xff3f)
954 //-----------------------------------------------------------------------------
955 // 2) REMO_NEC
956 // 187.714us ( 1.085*173 ) // (256-83) (0x10000-0xff53)
957 //
958 //****************************************************************************/
959 //INTERRUPT(5, timer2_int)
960 void timer2_int(void) interrupt 5 using 1 // using register block 3
961 {
962 1 TF2 = 0; // clear overflow
963 1
964 1 tm01++;
965 1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?