Hi,
I am implementing a simple HET in my test code. I am using TMS470R1B1M with Sysclk = 48 MHz. I am trying to generate simple PWM on HET_Pin_0. When I enable HET (HETGCR.bit_0 = 1) the code crashes with the error "Read memory error @ address 0xFFFFFE04, word access: Memory access timeout". I tried stepping through the assembly and the code seems to be putting the correct value in the register but the STR instruction puts the value 0x00010003 in R0 (which is GCR @ 0xFFF7FC00 for TMS470R1B1M). I am not sure what is wrong. Could you please help?
My test code is as follows:
main.c:
_no_init volatile HETPROGRAM0_UN e_HETPROGRAM0_UN @ 0x800000;
void MemCopy32(unsigned long *dst, unsigned long *src, int bytes)
{
for (int i = 0; i < (bytes + 3) / 4; i++)
*dst++ = *src++;
}
int main(void)
{
// Set up peripheral registers.
// First disable interrupts.
__disable_interrupt();
PCR = 0x1E;
PCR = 0x1F; // enable peripherals
HETGCR = CLK_MASTER + IGNORE_SUSPEND; // Disable HET & configure as master
// Copy the HET instructions to HET RAM
MemCopy32((void *) &e_HETPROGRAM0_UN, (void *) HET_INIT0_PST, sizeof(HET_INIT0_PST));
HETPFR = LRPRES_FACTOR_8 + HRPRES_FACTOR_6; // LRPRES_FACTOR_1 + HRPRES_FACTOR_48; // Set the PFR register (LR=1,HR=48)
HETDIR = HETDIR0; // Set the pin directions
HETGCR = CLK_MASTER + IGNORE_SUSPEND + 1; // Enable HET
for (;;)
{
}
}
het.c:
#include "std_het.h"
HET_MEMORY const HET_INIT0_PST[2] =
{
/* L00_0 */
{
0x00001600,
0x000000FA,
0x00000000,
0x00000000
},
/* L01_0 */
{
0x00000080,
0x00102018,
0x00001F40,
0x00000000
}
};
het.het:
; Configure the virtual counter
L00: CNT {next=L01, reg=A, irq=OFF, max=250, data=0}
; Pulse the HET0 pin
L01: ECMP {next=L00, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC0, action=PULSEHI, irq=OFF, data=250}
; This is commented - tried using MCMP instead of ECMP but still fails:
; L01: MCMP {next=L00, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC0, action=PULSEHI, order = REG_GE_DATA, irq=OFF, data=250}
;L01: BR {next=L00, cond_addr=L00, event=NOCOND}
PLEASE NOTE: When I comment out ECMP and MCMP and enable BR - then the code does not crash. The moment I enable ECMP or MCMP then the code crashes. Is there something not set up properly in ECMP/MCMP instruction or is there any open issue with these instructions?
I have attached a word file with screenshots of the crash. I am using IAR EW with J-Link. Any help would be appreciated.
Pinakin