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

📄 timer1.c

📁 Zigbee无线收发控制芯片JN5121C语言例程
💻 C
字号:
/****************************************************************************
 *
 * MODULE:             Timer1.c
 *
 * COMPONENT:          $RCSfile: $
 *
 * VERSION:            $Name: $
 *
 * REVISION:           $Revision: $
 *
 * DATED:              $Date: 30/06/06  $
 *
 * STATUS:             $State: $
 *
 * AUTHOR:             Gordon MacNee
 *
 * DESCRIPTION
 * code segment to demonstrate the operation of the timers
 * running in two modes of PWM
 * no interrupts are used in these routines
 *
 * CHANGE HISTORY:
 *
 * $Log: $
 *
 *
 * LAST MODIFIED BY:   $Author: pc1 $
 *                     $Modtime: $
 *
 *
 ****************************************************************************
 *
 *  (c) Copyright 2006 JENNIC Ltd
 *
 ****************************************************************************/

/****************************************************************************/
/***        Include files                                                 ***/
/****************************************************************************/

#include <jendefs.h>
#include <AppHardwareApi.h>

/****************************************************************************/
/***        Macro Definitions                                             ***/
/****************************************************************************/

/****************************************************************************/
/***        Type Definitions                                              ***/
/****************************************************************************/

/****************************************************************************/
/***        Local Function Prototypes                                     ***/
/****************************************************************************/

/****************************************************************************/
/***        Exported Variables                                            ***/
/****************************************************************************/

/****************************************************************************/
/***        Local Variables                                               ***/
/****************************************************************************/

/****************************************************************************/
/***        Exported Functions                                            ***/
/****************************************************************************/

/****************************************************************************/
/***        Local Functions                                               ***/
/****************************************************************************/

PRIVATE void vProcessEventQueues(void);

PRIVATE void vTimerConfig(void);


/****************************************************************************
 *
 * NAME: vTimerConfig
 *
 * DESCRIPTION:
 * PWM output from timer0 in Delta Sigma mode
 * with a low period of 0x8000 and a high of (0xffff - 0x8000)
 *
 * PWM output from timer1 in standard PWM mode
 * with a low period of 0x8000 and a high of (0xffff - 0x8000)
 *
 * PARAMETERS:      Name            RW  Usage
 * None.
 *
 * RETURNS:
 * None.
 *
 * NOTES:
 * In this mode the period of timer0 is fixed
 * at 2^16 or 2^17 and the u16Lo the SPACE period
 ****************************************************************************/
PRIVATE void vTimerConfig(void)
{
/* set up timer 0 for Sigma Delta PWM */
    vAHI_TimerEnable(E_AHI_TIMER_0,
                     0x00,
                     FALSE,
                     FALSE,
                     TRUE);
    vAHI_TimerClockSelect(E_AHI_TIMER_0,
                          FALSE,
                          TRUE);
    vAHI_TimerStartDeltaSigma(E_AHI_TIMER_0,
                              0x0000,   // null value
                              0x8000,   // low period (space) u16Lo
                              FALSE);

/* set up timer 1 for PWM */
    vAHI_TimerEnable(E_AHI_TIMER_1,
                     0x00,
                     FALSE,
                     FALSE,
                     TRUE);
    vAHI_TimerClockSelect(E_AHI_TIMER_1,
                          FALSE,
                          TRUE);
    vAHI_TimerStartRepeat(E_AHI_TIMER_1,
                          0x8000,       // low period (space)
                          0xffff);      // period
}


/****************************************************************************
 *
 * NAME: AppColdStart
 *
 * DESCRIPTION:
 *
 * PARAMETERS:      Name            RW  Usage
 * None.
 *
 * RETURNS:
 * None.
 *
 * NOTES:
 * Entry point for a power on reset or wake from sleep mode.
 ****************************************************************************/
PUBLIC void AppColdStart(void)
{

    /* Initialise stack and hardware interfaces.  */
    (void)u32AHI_Init();

    /* configure and start timer 0 and 1 running different PWM types */
    vTimerConfig();

    /* just sit in this loop and let the hardware run the PWM */
    while(1)
    {
    }
}

/****************************************************************************
 *
 * NAME: AppWarmStart
 *
 * DESCRIPTION:
 * Entry point for a wake from sleep mode with the memory contents held. We
 * are not using this mode and so should never get here.
 *
 * PARAMETERS:      Name            RW  Usage
 * None.
 *
 * RETURNS:
 * None.
 *
 * NOTES:
 * None.
 ****************************************************************************/
PUBLIC void AppWarmStart(void)
{
    AppColdStart();
}




/****************************************************************************/
/***        END OF FILE                                                   ***/
/****************************************************************************/

⌨️ 快捷键说明

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