首页 > 其他 > 详细

DSP 之看门狗定时器(WDTIM)和主机设备接口(HPI)

时间:2014-02-23 01:36:31      阅读:507      评论:0      收藏:0      [点我收藏+]

DSP 之看门狗定时器(WDTIM)和主机设备接口(HPI)

        看门狗定时器(WDTIM):

/*
 * Copyright (C) 2003 Texas Instruments Incorporated
 * All Rights Reserved
 */



#include <csl.h>
#include <csl_wdtim.h> 
#include <stdio.h>



int i, pscVal;
WDTIM_Config getConfig;

/* Structure used to configure a WDTIM device */
WDTIM_Config myConfig = {
     0x1000,          /* WDPRD Period register(周期寄存器) */
     0x0000,          /* WDTCR Control register(控制寄存器) */
     0x1000           /* WDTCR2 Secondary register(辅助寄存器) */
};



void main(void)
{
	/* Initialize CSL Libary */
    CSL_init();
    printf ("\nTESTING...\n");
  	
  	/* Configures WDTIM using configuration structure */
    WDTIM_config(&myConfig);
    
    /* Macros to write WDTIM register field values */
    WDTIM_FSET(WDTCR, WDOUT, 1);	/* Connect to NMI */
    WDTIM_FSET(WDTCR, TDDR, 0xF);	/* Value to load PSC field */    
    WDTIM_FSET(WDTCR2, PREMD, 0);	/* Set direct mode */
    
    /* Executes the watchdog service sequence */
    WDTIM_service();				/* enable watchdog */ 
          
    while(1)
    {   
    	/* Gets the WDYIM configuration structure for a specified device */                  
        WDTIM_getConfig(&getConfig);  
        
        /* Macros to read WDTIM register field value */
        pscVal = WDTIM_FGET(WDTCR,PSC);

        printf("pscVal: %x, wdtcr: %x\n", pscVal, getConfig.wdtcr);    
        
       
        /* write periodically to WDTIMER  - when this line is commented out,
           the watchdog times out, WDFLAG set to 1, indicating 
           that a Watchdog time-out occurred.*/ 
           
        WDTIM_service();         
    }           
}

主机设备接口(HPI):

/*--------------------------------------------------------------------------
 * Project: HPI.c
 * Name: zwp
 * Date: 2014.2
 *-------------------------------------------------------------------------*/
 
 
 
 
#include <csl.h>
#include <csl_hpi.h>
#include <csl_dma.h>


ioport Uint16* hpi_ctl;

HPI_Config myconfig;

DMA_Handle hDma;

/* 主机接口设置 */
HPI_Config myConfig = {
	0x3,		/* HPWREMU, Select FREE = SOFT = 1 */
	0x0,		/* HGPIOEN, Disable all GPIO pins	*/
	0x80,		/* HPIC,	Reset HPI				*/
};



int main(void)
{
	 Uint16 myregval;
	 Uint16 myvar;
	 
	/*初始化CSL库*/	
    CSL_init();
    
    /* Writes to HPI register using values in configuration structure */
    HPI_config(&myConfig);
    
    /* Reads current HPI configuration */
    HPI_getConfig(&myconfig);
    
    /* gets the address of an HPI register */
    hpi_ctl = HPI_ADDR(HPIC);
    printf("HPI register‘s address = %d\n", hpi_ctl);
    
   
	/* enable HA[0:7], HD[8:15], HD[0:7] for GPIO */
	myregval = HPI_HGPIOEN_RMK (0,1,1,1,0,0,0,0,0);
	
	/* set HPI register value */
	HPI_RSET(HPIC, 1);
	
	/* get HPI register value */
	myval = HPI_RGET(HPIC);	
    
    return 0;
    
    
	
	
}


 
 
 



 

 

 

 

 

DSP 之看门狗定时器(WDTIM)和主机设备接口(HPI)

原文:http://blog.csdn.net/qqzwp/article/details/19678599

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!