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

📄 power.c

📁 Dignostic test program for SMDK441f board chip peripellel. ADS1.2 compiler
💻 C
字号:
#include "def.h"
#include "option.h"
#include <string.h>
#include "k44.h"
#include "k44lib.h"


static volatile int cntEint0,cntEint1,cntEint2;
static volatile int tmcCnt0,tmcCnt1,tmcCnt2,tmcCnt3,tmcCnt4,tmcCnt5;

static void __irq IsrEint0(void)
{
    rINTPEND=~BIT_EINT0;  
    cntEint0++;
}


static void __irq IsrEint1(void)
{
    rINTPEND=~BIT_EINT1;  
    cntEint1++;
}


static void __irq IsrEint2(void)
{
    rINTPEND=~BIT_EINT2;  
    cntEint2++;
}


static void __irq IsrT0MC(void)
{
    rINTPEND=~BIT_T0MC;  
}


static void __irq IsrT1MC(void)
{
    rINTPEND=~BIT_T1MC;  
}

static void __irq IsrT2MC(void)
{
    rINTPEND=~BIT_T2MC;  
}

static void __irq IsrT3MC(void)
{
    rINTPEND=~BIT_T3MC;  
}

static void __irq IsrT4MC(void)
{
    rINTPEND=~BIT_T4MC;  
}

static void __irq IsrT5MC(void)
{
    rINTPEND=~BIT_T5MC;  
}



void Test_IdleMode(void)	
{
    Uart_Printf("IDLE mode test.\n");
    Uart_Printf("Push GPIO0 key to wake up!!!\n");

    rP0CON=rP0CON&(~0x1); //GPIO0=input
      //test board GPIO0 is connected to EINT0,1,2 and switch.
      //So, GPIO0 should be input to test EINT0,1,2 by switch.
      
    pISR_EINT0=(unsigned)IsrEint0;
    pISR_EINT1=(unsigned)IsrEint1;
    pISR_EINT2=(unsigned)IsrEint2;

    cntEint0=0; 
    cntEint1=0;
    cntEint2=0;
    
    rEINTMOD=(0<<4)|(0<<2)|(0);//falling edge
    rEINTCON=0x7; //EINT0,1,2 interrupt is enabled.

    rINTMASK=BIT_EINT0|BIT_EINT1|BIT_EINT2;

    rSYSCON|=2;  //enter IDLE mode.
    __asm
    {
    	nop;
    	nop;
    	nop;
    	nop;
    }

    //Wait any interrupts. MCU is in IDLE mode now.
    Uart_Printf("cntEint0=%d, cntEint1=%d,cntEint2=%d\n",1,1,1);
    Uart_Printf("cntEint0=%d, cntEint1=%d,cntEint2=%d\n",cntEint0,cntEint1,cntEint2);

    rP0CON=rP0CON|1; //GPIO0=output
}




void Test_IdleModeWithTimer(void)
{
    int i;
    Uart_Printf("IDLE mode test by 6 timers.\n");

    pISR_T0MC=(unsigned)IsrT0MC; //to signal the interrupt period outside
    pISR_T1MC=(unsigned)IsrT1MC;
    pISR_T2MC=(unsigned)IsrT2MC;
    pISR_T3MC=(unsigned)IsrT3MC;
    pISR_T4MC=(unsigned)IsrT4MC;
    pISR_T5MC=(unsigned)IsrT5MC;

    tmcCnt0=tmcCnt1=tmcCnt2=tmcCnt3=tmcCnt4=tmcCnt5=0;

    rINTMASK=BIT_T0MC|BIT_T1MC|BIT_T2MC|BIT_T3MC|BIT_T4MC|BIT_T5MC;
  
    rT0PRE=199; 	//100khz(20Mhz/200)
    rT1PRE=199;
    rT2PRE=199;
    rT3PRE=199;
    rT4PRE=199;
    rT5PRE=199;
    
    rT0DATA=99; 	//100khz/(99+1)=1khz
    rT1DATA=98;
    rT2DATA=97;
    rT3DATA=96;
    rT4DATA=95;
    rT5DATA=94;
            
    rT0CON=0xc0;	//En CLR ITVAL EXTCLK 00
    rT1CON=0xc0;	//1  1   000   0      00
    rT2CON=0xc0;
    rT3CON=0xc0;
    rT4CON=0xc0;
    rT5CON=0xc0;
  	
    for(i=0;i<2000;i++)
    {
        rSYSCON|=2;  //enter IDLE mode.
    	__asm
    	{	
    	    nop;
    	    nop;
    	    nop;
    	    nop;
        }
        Uart_Printf(".");
    }
    rT0CON=0x0;	//Dis NCLR MC&OVF   EXTCLK 00
    rT1CON=0x0;	//0   0    000      0      00
    rT2CON=0x0;
    rT3CON=0x0;
    rT4CON=0x0;
    rT5CON=0x0;

    Uart_Printf("\n");
    
    rINTMASK=0x0;
}


void Test_StopMode(void)	
{
    Uart_Printf("STOP mode test.\n");
    Uart_Printf("Push GPIO0 key to wake up!!!\n");
    Uart_TxEmpty();

 
    rP0CON=rP0CON&(~0x1); //GPIO0=input
      //test board GPIO0 is connected to EINT0,1,2 and switch.
      //So, GPIO0 should be input to test EINT0,1,2 by switch.

    pISR_EINT0=(unsigned)IsrEint0;
    pISR_EINT1=(unsigned)IsrEint1;
    pISR_EINT2=(unsigned)IsrEint2;

    cntEint0=0; 
    cntEint1=0;
    cntEint2=0;
    
    rEINTMOD=(0<<4)|(0<<2)|(0);//falling edge
    rEINTCON=0x7; //EINT0,1,2 interrupt is enabled.

    rINTMASK=BIT_EINT0|BIT_EINT1|BIT_EINT2;

    rSYSCON|=1;  //enter STOP mode.
    __asm
    {
    	nop;
    	nop;
    	nop;
    	nop;
    }

    //Wait any interrupts. MCU is in IDLE mode now.
    Uart_Printf("cntEint0=%d, cntEint1=%d,cntEint2=%d\n",1,1,1);
    Uart_Printf("cntEint0=%d, cntEint1=%d,cntEint2=%d\n",cntEint0,cntEint1,cntEint2);

    rP0CON=rP0CON|1; //GPIO0=output

}

⌨️ 快捷键说明

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