📄 tms470r1b1m_het_int_01.c
字号:
//*****************************************************************************
// TMS470 Demo - HET Interrupt Sample Program
//
// Program name : tms470r1b1m_HET_INT_01.c, associated with
// HET program tms470r1b1m_HET_INT_01_H.het
//
// Description; This program uses the HET to interrupt the CPU. The
// interrupt in this example flashes the LEDs on HET0..7 on the EVM.
//
// SYSCLK = MCLK = ACLK = 8 x 7.3728MHz = 58.9824MHz
// ICLK = SYSCLK / 2 = 29.4912MHz
//
// //*An external 7.3728MHz XTAL with proper load caps is required*//
//
// TMS-FET470B1M
// -----------------
// | OSCIN|-
// | | 7.3728MHz
// +--|PLLDIS OSCOUT|-
// | | |
// -+- | HET0..7|---> 8 HET LEDs
// | |
//
// J.Mangino / A.Dannenberg
// Texas Instruments, Inc
// July 29th 2005
// Built with IAR Embedded Workbench Version: 4.30A
//******************************************************************************
#include <intrinsic.h>
#include "iotms470r1b1m.h"
#include "tms470r1b1m_bit_definitions.h"
#include "std_het.h"
#include "tms470r1b1m_HET_INT_01_H.h"
__no_init volatile HETPROGRAM0_UN e_HETPROGRAM0_UN @ 0x00800000;
void MemCopy32(unsigned long *dst, unsigned long *src, int bytes);
void HET_CNT_INT();
void HET1_irq_handler();
void main(void)
{
PCR = CLKDIV_2; // ICLK = SYSCLK / 2
GCR = ZPLL_CLK_DIV_PRE_1; // SYSCLK = 8 x fOSC
PCR |= PENABLE; // Enable peripherals
REQMASK = (1 << CIM_HET1); // Enable HET Interrupt mask
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));
HETPRY = 0x01; // Int on instruction 1 is
// high-priority
HETPFR = 0x0000052b; // Set PFR register
HETDCLR = 0xffffffff; // Clear HET output latches
HETDIR = 0xffffffff; // Set HET as GIO outputs
HETGCR |= ON; // Start HET
__enable_interrupt(); // Enable Interrupts
while (1); // Loop forever...
}
//------------------------------------------------------------------------------
// This module programms the HET RAM with the HET code
//------------------------------------------------------------------------------
void MemCopy32(unsigned long *dst, unsigned long *src, int bytes)
{
for (int i = 0; i < (bytes + 3) / 4; i++)
*dst++ = *src++;
}
//------------------------------------------------------------------------------
// TMS470R1B1M Standard Interrupt Handler
//------------------------------------------------------------------------------
__irq __arm void irq_handler(void)
{
switch ((0xff & IRQIVEC)-1)
{
case CIM_HET1 :
HET1_irq_handler();
break;
}
}
//------------------------------------------------------------------------------
// HET Instruction 0 Interrupt Handler
//------------------------------------------------------------------------------
void HET_CNT_INT()
{
HETDOUT ^= 0xff; // Toggle HET0..7 LEDs
}
//------------------------------------------------------------------------------
// HET Interrupt Handler
//------------------------------------------------------------------------------
void HET1_irq_handler()
{
switch ((0xff & HETOFF1)-1)
{
case 0 : // Instruction 0
HET_CNT_INT();
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -