#include "hal_pwm.h"

//PE2--TIMA_3_PWM5   PE3--TIMA_3_PWM6

void time_pwm_out(void)
{
    stc_tmra_init_t stcTmraInit;
    stc_tmra_pwm_init_t stcPwmInit;

    /* 1. Enable TimerA peripheral clock. */
    FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMRA_3, ENABLE);

    /* 2. Set a default initialization value for stcTmraInit. */
    (void)TMRA_StructInit(&stcTmraInit);

    /* 3. Modifies the initialization values depends on the application. */
    stcTmraInit.sw_count.u16CountMode = TMRA_MD1;
    stcTmraInit.sw_count.u16CountDir  = TMRA_DIR1;
    stcTmraInit.u32PeriodValue = TMRA_PERIOD_VAL1;
    (void)TMRA_Init(TMRA_UNIT1, &stcTmraInit);

    /* 4. Set the comparison reference value. */
    (void)TMRA_PWM_StructInit(&stcPwmInit);
    stcPwmInit.u32CompareValue = TMRA_PWM_CMP_VAL1;
    GPIO_SetFunc(TMRA_PWM_PORT1, TMRA_PWM_PIN1, TMRA_PWM_PIN_FUNC1);
    (void)TMRA_PWM_Init(TMRA_UNIT1, TMRA_PWM_CH1, &stcPwmInit);
    TMRA_PWM_OutputCmd(TMRA_UNIT1, TMRA_PWM_CH1, ENABLE);
		
		
    /* 3. Modifies the initialization values depends on the application. */
    stcTmraInit.sw_count.u16CountMode = TMRA_MD2;
    stcTmraInit.sw_count.u16CountDir  = TMRA_DIR2;
    stcTmraInit.u32PeriodValue = TMRA_PERIOD_VAL2;
    (void)TMRA_Init(TMRA_UNIT2, &stcTmraInit);

    /* 4. Set the comparison reference value. */
    (void)TMRA_PWM_StructInit(&stcPwmInit);
    stcPwmInit.u32CompareValue = TMRA_PWM_CMP_VAL2;
    GPIO_SetFunc(TMRA_PWM_PORT2, TMRA_PWM_PIN2, TMRA_PWM_PIN_FUNC2);
    (void)TMRA_PWM_Init(TMRA_UNIT2, TMRA_PWM_CH2, &stcPwmInit);
    TMRA_PWM_OutputCmd(TMRA_UNIT2, TMRA_PWM_CH2, ENABLE);		
		
		
		TMRA_Start(TMRA_UNIT1);
}




