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

📄 pwm.c

📁 ucosii移植到44b0的代码
💻 C
字号:
#include <string.h>
#include "../inc/option.h"
#include "../inc/44b.h"
#include "../inc/44blib.h"
#include "../inc/def.h"


void __irq Timer0Done(void);
volatile int variable0;

void Main(void)
{

     
   
    rSYSCFG = CACHECFG;  

    Port_Init();
    Uart_Select( 0 ) ;
    Uart_Init( 0, 115200 ) ;
      
      rINTMSK = 0x7ffffff;	  // All interrupt is masked.   
   
    pISR_Tick=(int)Timer0Done;  
	 

     rINTCON = 0x5 ;		//无向量中断模式	
	rINTMOD = 0x0 ;		//All=IRQ mode		
                    
    
    Uart_Printf("\n[Timer Test 1]\n");

         rPCONC=0x55;
     rPCONE=0x0;

    
    Uart_Printf("\n[Timer Test 2]\n");
	    Uart_Printf("\n[Timer Test 3]\n");

    rTCFG0=0x63;	//dead pre0=0xf
 Uart_Printf("\n[Timer Test 4]\n");
    rTCFG1=0x03;	//all interrupt,mux5=1/2,mux2=1/2,mux3=1/4,mux2=1/8,mux1=1/16,mux0=1/32
    
    rTCNTB0=0xc350;	//(1/(40MHz/100/16))*0xc350=2s
    Uart_Printf("\n[Timer Test 5]\n");

    rTCMPB0=0x61A8;
     Uart_Printf("\n[Timer Test 5]\n");


    
   Uart_Printf("\n[Timer Test 5]\n");

    rINTMSK= ~(BIT_GLOBAL|BIT_TIMER0);    
    Uart_Printf("\n[Timer Test 5]\n");
    variable0=1;
	

    rTCON=0x2;	//update T0  rTCON=0x0,rTCON=0x2都可以?但必须得有!后来发现0不可以!
    //rTCON=0x09;
    rTCON=0x09;
    
   
   while(1)
    {
    
   /*if(rTCNTO0==1)
    Uart_Printf("__|");*/
    
    if(rTCNTO0==25000)
    { Uart_Printf("\n[Timer Test 6]\n");
        rPDATC=variable0;
    	
 
  Uart_Printf("--|");
Uart_Printf("__|");
    
  }
  }

}

void __irq Timer0Done(void)
{Uart_Printf("\n[Timer Test 6]\n");
    rI_ISPC=BIT_TIMER0;
    variable0--; 
if( !variable0)
 variable0=16;   
Uart_Printf("\n%d\n",variable0);
}

⌨️ 快捷键说明

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