Other Parts Discussed in Thread: TMS470R1B1M,
IAR开发环境
为啥HET中断参考例程下载到板子里,无法完成相应功能,连接在HET【4】上的LED灯不会闪烁
.het文件L00: CNT {next=L00, reg=A, irq=ON, max=0x214A, data=0}使用CNT指令定时打开中断,使HET【4】上产生高低电平
main.c
#include <stdio.h>
#include <string.h>
#include <intrinsics.h>
#include <TexasInstruments/iotms470r1b1m.h>
#include <TexasInstruments/tms470r1B1m_bit_definitions.h>
#include "std_het.h"
#include "pwm.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++;
}
int main(void)
{
__disable_interrupt();//关中断
PCR = CLKDIV_16; // ICLK = SYSCLK / 16
GCR |= ZPLL_CLK_DIV_PRE_8; // SYSCLK = 8 x fOSC,+ FLCONFIG
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
HETDCLR = 0xffffffff; // Clear HET output latches
HETDIR = 0xffffffff; // Set HET as GIO outputs
HETGCR |= ON; // Start HET
REQMASK = (1 << CIM_HET1);
__enable_interrupt(); // Enable Interrupts
while (1); // Loop forever...
}
void HET1_irq_handler()
{
switch ((0xff & HETOFF1)-1)
{
case 0 : // Instruction 0
HETDOUT ^= 0xff;
HETFLG |= 0x01;
break;
}
}
__irq __arm void irq_handler(void)
{
switch ((0xff & IRQIVEC)-1)
{
case CIM_HET1 :
HET1_irq_handler();
break;
}
}