⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lst

📁 CS8955控制TV软件。用MCU做模拟电视的控制。
💻 LST
📖 第 1 页 / 共 3 页
字号:
 271   3                SBUF = _PrinTBuf[_bTNum-1];   while(!TI);   TI = 0;    
 272   3              
 273   3           }
 274   2      }
 275   1         SBUF =  ' ';   while(!TI);   TI = 0;    
 276   1      
 277   1                
 278   1       i=0; 
 279   1      if(bV4 == 0)
 280   1        {
 281   2              SBUF =  '0';   while(!TI);   TI = 0;    
 282   2               SBUF =  '0';   while(!TI);   TI = 0;           
 283   2        }
 284   1      else
 285   1      {
 286   2       while((bV4)&&(i<4))    
 287   2        {   
 288   3               _PrinTBuf[i++]   =   szTable[bV4%10];   
 289   3             bV4  /= 10;   
 290   3        } 
 291   2        _bTNum=i;
 292   2       for( _bTNum=i; (_bTNum>0) && (_PrinTBuf[_bTNum-1]); _bTNum--)
 293   2          {      
 294   3            
 295   3                SBUF = _PrinTBuf[_bTNum-1];   while(!TI);   TI = 0;    
 296   3              
 297   3           }
C51 COMPILER V8.05a   MAIN                                                                 01/05/2009 15:57:47 PAGE 6   

 298   2      }
 299   1         SBUF =  ' ';   while(!TI);   TI = 0;    
 300   1      
 301   1         SBUF = 0x0D;   while(!TI);   TI = 0;   // CR ( ^M )
 302   1         SBUF = 0x0A;   while(!TI);   TI = 0;   // LF ( ^J )
 303   1         
 304   1        CS8955_PADMOD2=0xa0;   //Set " 1"  for (Master IIC) HSDA1 HSCL1,HSDA2,HSCL2,
 305   1      }
 306          #endif
 307          
 308          
 309          #ifdef ENABLE_UART
              // Init Uart
              void vInitUart()
              {
                  UartRxIndex = 0; 
              
                CS8955_PADMOD2=0x00; //martin 16Oct08 0x74;     P3.0,P3.1,P1.5,P1.6 Set " 0"  for  I/O PORT with printf 
             -variable
              
                 PCON |= 0x80; //UART  baud rate double control(C51 book page 158)
                 SCON = 0x50;        // mode1 & enable receive
              
                     CS8955_ETCTR &=0xF0;                             /* EXEN2=0; TR2=0; C/T2#=0; CP/RL2#=0; */ //02Sep08
                      CS8955_ETCTR |=0x30;                            /* RCLK = 1; TCLK=1; */    //02Sep08
                     CS8955_ETCTR|=0x04;            /*TR2=1; Timer 2 run */   //02Sep08
                     CS8955_ETMOD = 0x00;   //02Sep08
              
               //      CS8955_THET=256-(62500/9600);  /* init value */
               //      CS8955_TLET=0xFD;                                /* init value */
               //      CS8955_RCAPETH=256-(62500/9600);                         /* reload value, baud_Rate Bds at 22.118
             -MHz */
               //      CS8955_RCAPETL=0xFD;     
                CS8955_TLET   = 0;
                 CS8955_THET   = 0;   
              //CS8955_THET= (65536-(12000000/32/4800))/256;  
              //       CS8955_TLET=(65536-(12000000/32/4800))%256;  // 4800 ok , 9600 fail    
               CS8955_RCAPETL  = (65536-(12000000/32/4800))%256;  // 4800 ok , 9600 fail
                 CS8955_RCAPETH  = (65536-(12000000/32/4800))/256;  
              
                //02Sep08  PT1= 0;   // priority Timer1 level
               //02Sep08   ET1 = 0; // Disable timer1 interrupt
               //02Sep08   TR1 = 1; // start timer1
               
                 ES = 1;   // enable serial interrupt
               //02Sep08  PS = 0;  // priority serial low
              
              
              
               
              //02Sep08 CS8955_PADMOD2=0xa0; //0xE0; 
              
              //fgEnUART=0;  //03Jul08 test
              
              // printf("UART is ok\n"); 
                 
              }
              #endif
 354          
 355          // Init CPU
 356          void vInitCPU(void)
 357          {
C51 COMPILER V8.05a   MAIN                                                                 01/05/2009 15:57:47 PAGE 7   

 358   1          vInitIO();  //P0-P3
 359   1          vInitTimer();   //Timer 0 Init
 360   1                            
 361   1           #ifdef SUPPORT_UART_PRINTF //   //25Aug08 test UART
 362   1           PCON = 0x80;
 363   1          SCON  = 0x50;       
 364   1          CS8955_RCAPETL  = (65536-(12000000/32/4800))%256;  // 4800 ok , 9600 fail
 365   1         CS8955_RCAPETH  = (65536-(12000000/32/4800))/256;    
 366   1         CS8955_ETCTR = 0x34;
 367   1         CS8955_ETMOD = 0x00;
 368   1         CS8955_TLET   = 0;
 369   1         CS8955_THET   = 0;   
 370   1           DRS232LogS("System Init Start.\n");        
 371   1        #else
                     #ifdef ENABLE_UART
                      vInitUart();    
                    #endif     
                 #endif               
 376   1      
 377   1           vInitVar();
 378   1              
 379   1      }
 380          #ifdef MARTIN_SYSTEM_ONLY_TVMODE  //martin 08Mary08
 381          void vInitSys(void)   //martin 12May08
 382          {
 383   1              TR0=1;   // start timer0                                                
 384   1              //      EX0 = 1;  // IR         
 385   1           #ifdef SUPPORT_UART_PRINTF  //26Aug08
 386   1             //  ES = 1;   // enable serial interrupt
 387   1              TI = RI = 0;
 388   1          #else   
                     #ifdef ENABLE_UART  //#if (defined(ENABLE_UART) || defined(SUPPORT_UART_PRINTF))//   #ifdef ENABLE_
             -UART
                        ES = 1;   // enable serial interrupt
                       TI = RI = 0;
                     #endif     
                 #endif
 394   1           EA = 1;      //27Aug08
 395   1      
 396   1          vInitialE2prom();   
 397   1      
 398   1           vInitTV(); 
 399   1               
 400   1            #ifdef SUPPORT_UART_PRINTF       
 401   1               DRS232LogS("ChIndex System Sound: .\n");       
 402   1               DRS232LogB(bTvCurrChIndex,sTvCurrChannel.bSystem,bTvCurrSound,0xff);
 403   1              DRS232LogS("System Init Finish.\n");    
 404   1               DRS232LogS("Software Version:");       
 405   1               DRS232LogB(fgTvVersion,0,0,0);  //26Aug08      
 406   1         #endif
 407   1               CS8955_PADMOD2=0xa0;  //Set " 1"  for (Master IIC) HSDA1 HSCL1,HSDA2,HSCL2,
 408   1         
 409   1           
 410   1      }
 411          #else
              // Init sys pwr
              
              
              void vSysModeSwitch(BYTE mode)
              {
                      switch (mode)
                      {
C51 COMPILER V8.05a   MAIN                                                                 01/05/2009 15:57:47 PAGE 8   

                              case DVD_MODE:
                                      mTVDisable();
                                      break;
                              case TV_MODE:
                                      vInitTV();
                                      break;
                      }
              }
              #endif
 428          #ifndef MARTIN_MCU_NO_IR   //martin 08May08
              /////////////////// IR interrupt service routines////////////////////
              void ISR_EXINT0(void) interrupt 0 
              {
                  BYTE bKey;
              
                  EA = 0;
              
                  // Scan the remote control
                  bKey = bRemoteDetect();
              
                  // key is detected
                  if (bKey != IR_NONE)
                  {
                      if ((bKey == IR_LONGPUSH) && (_bIRLongPush == IR_NONE)
                              && (_bIRKey0!=IR_LONGPUSH) )
                      {
                              _bIRLongPush = _bIRKey0;
                      }
              
                      if (bKey != IR_LONGPUSH)
                      {
                              _bIRLongPush = IR_NONE;
                              _bIRKey0 = bKey;
                             _fgIRKeyValid = TRUE;
                      }
                     // long push
                      else     if (_bIRLongPush!=IR_NONE)
                      {
                              _bIRKey0 = Key2IR(TRUE,_bIRLongPush);
                              _bIRLongPush = IR_NONE;
                             _fgIRKeyValid = TRUE;
                        }
                  }   
              
                  EA = 1;     
              }
              #endif
 466          //System Clock  20ms
 467          void ISR_Timer0(void) interrupt 1  // 20ms task 
 468          {
 469   1           EA = 0;
 470   1           TH0=0xEC;   //timer 0 high byte
 471   1           TL0=0x78;    //timer 0 low byte
 472   1              
 473   1          if (!(--wTimer0Count))
 474   1          {
 475   2             bTimer20ms = 1;
 476   2             wTimer0Count = 5;
 477   2          }
 478   1      
 479   1          if (EEP_Wait>0)
 480   1              --EEP_Wait;
C51 COMPILER V8.05a   MAIN                                                                 01/05/2009 15:57:47 PAGE 9   

 481   1      
 482   1           TF0 = 0;
 483   1           EA = 1;
 484   1      }
 485          BYTE uart_data;  //04Sep08 test
 486          
 487          #ifdef ENABLE_UART
              void ISR_UART(void) interrupt 4 // Uart
              {
              /*
                 EA = 0;
                 if(RI)
                 {
                      if (SBUF!=0x0d && SBUF!=0x0a)
                      {
                              UartRxBuf[UartRxIndex++] = SBUF;
                              if (UartRxIndex>=UART_BUF_SIZE)
                                      UartRxIndex = 0;
                      }               
                      RI = 0;
                 }
                 EA = 1;
              */
              
              
                      if (RI == 1) 
                      {                                                /* if reception occur */
                        RI = 0;                                  /* clear reception flag for next reception */
                        uart_data = SBUF;          /* Read receive data */
                        SBUF = uart_data;             /* Send back same data on uart*/
                        while(TI==0);
                        TI=1;
                      
                      }       
                                                      /* clear emission flag for next emission*/      
                 
              }
              #endif
 519          
 520              #ifndef MARTIN_DVD_COMM_NOT_SUPPORT_INT     
              
              // DVD communication
              void ISR_INT2(void) interrupt 2
              {
              #ifndef MARTIN_DVD_COMM_NOT_SUPPORT_INT 
                  BYTE i, count;
              #endif
              
              #ifndef MARTIN_SYSTEM_ONLY_TVMODE       
                  EA = 0;
                  if (SysMode!=PWR_DOWN_MODE)  //needn't judge  mode
              #endif          
                  {
              
                      while (mReadDvdClk())
                      {
                                 if (mReadDvdCs())
                                 {
                                    goto _EINT2_EXIT;
                                 }    
                      }
                      for (i=0;i<(COMDVD_BYTE);i++)
C51 COMPILER V8.05a   MAIN                                                                 01/05/2009 15:57:47 PAGE 10  

                      {
                          DvdRxIndex = i;
                         DvdRxBuf[DvdRxIndex] = 0;
                          for (count=0x80;count>0;count>>=1)
                         {
                              // data out      
                              if (DataOutValid)
                              {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -