?? het_pwm_01.c
字號:
//******************************************************************************
// TMS470 Demo - HET used to generate PWM
//
// Program name : HET_PWM_01.c associated with HET program HET_PWM_01_H.het
//
// This programs initializes the HET using the ECMP instruction to
// generate two PWMs of 25% and 50% duty cycle. The pulses is generated by the
// HET on CC0 and CC2 lighting the corresponding LEDs.
//
// *An external 12Mhz XTAL on OSCIN OSCOUT with proper load caps required*
//
// TMS-FET470A256
// -----------------
// /|\| OSCIN|-
// | | | 12MHz
// --|PLLDIS OSCOUT|-
// | |
// | CC0 |---> LED
// | |
// | CC2 |---> LED
// | |
//
// John Mangino / Andreas Dannenberg
// Texas Instruments, Inc
// May 2005
// Built with IAR Embedded Workbench Version: 4.20A
// A256 EVM
//******************************************************************************
#include <intrinsic.h>
#include "iotms470r1a256.h"
#include "tms470r1a256_bit_definitions.h"
#include "std_het.h"
#include "HET_PWM_01_H.h"
__no_init volatile HETPROGRAM0_UN e_HETPROGRAM0_UN @ 0x00800000;
void MemCopy32(unsigned long *dst, unsigned long *src, int bytes)
{
for (int i = 0; i < (bytes + 3) / 4; i++)
*dst++ = *src++;
}
void main(void)
{
// Set up peripheral registers.
// First disable interrupts.
__disable_interrupt();
PCR = CLKDIV_1; // ICLK = SYSCLK/4
PCR |= PENABLE; // enable peripherals
HETGCR = CLK_MASTER + IGNORE_SUSPEND; // HET Master Mode, Ignore SW BP
// copy HET instructions to HET ram
MemCopy32((void *) &e_HETPROGRAM0_UN, (void *) HET_INIT0_PST,
sizeof(HET_INIT0_PST));
HETPFR = 0x0000052b; // Set PFR register
HETDIR = 0xFFFFFFFF; // Set all HET as GIO outputs
HETDOUT = 0xFFFFFFFF; // Flash all leds off and on and off
HETGCR |= ON; // Start HET
__enable_interrupt(); // Enable Interrupts
while(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -