This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL2-RM57L: Can't Get HTU to Work

Part Number: LAUNCHXL2-RM57L
Other Parts Discussed in Thread: HALCOGEN

Hi,

I'm trying to develop using the N2HETs running a program, then use the HTU to transfer data to the ARM CPU. I've gotten the N2HETs working, so now I'm trying to get the HTU to work. I've been going off the example for generating a sine wave (on the processor's document page). It makes sense to me what's going on, and I've written something very similar for my application that I'm using as a "test bed" (I've even loaded the sine wave project into CCS and that didn't work either, but I didn't check to make sure that everything was the same in terms of mapping to register addresses and such). Was wondering if anyone could see if there are any issues with the code that I've written. Been beating my head against my desk for the last few days...

Also, I'm not using HalCoGen code, since this it's not something that I can use right now for this project (and I like writing this stuff from the ground up, for some reason), but hopefully the register names make sense.

The program will just use N2HET2 (as a control, not using THU on this) running a PWM at 75% duty cycle. N2HET1 runs at 25% by default (program written initially to the RAM), but then after a cycle, the HET should get a new value from memory for a new duty cycle. The problem is that it's not getting the value. It stays at the default duty cycle.

Hopefully that's enough, and not painful to look through, but if it's not let me know and I'll provide what I can.

Main program:

int main(void) {
	/*
	 * Initialize the HTU
	 */
	DCP1REG->DCPx[0].ITCOUNT = (1 << 16) | (1 << 0); // Do a single element transfer and a single frame transfer
	DCP1REG->DCPx[0].IHADDRCT = (1 << 23) | // Main memory is read and NHET memroy is written.
	                            (1 << 18) | // Set to circular buffer mode
	                            (24 << 2); // Set the initial NHET address (the data field of ECMP is address 6)
	DCP1REG->DCPx[0].IFADDRA =  (uint32_t)&data; // Set the initial address in main memory
	DCP1REG->CDCPx[0].CFADDRA = 0; // Clear the current address
	DCP1REG->CDCPx[0].CFCOUNT = 0; // Clear the current count
	HTU1REG->CPENA = 1; // Enable DCP[0] control packet A
	HET1REG->GCR = (1 << 16); // Enable HTU1

	/*
	 * Initialize the N2HETs
	 * The HTU is attached to N2HET1
	 */
	HET1REG->DIR |= (1 << 0); // Enable N2HET1[0] pin for output
	HET2REG->DIR |= (1 << 0); // Enable N2HET2[0] pin for output
	
	// Set the resolution pre-scalars
	n2het1_hr_set(0);
	n2het1_lr_set(6);
	n2het2_hr_set(0);
	n2het2_lr_set(6);

    HET1REG->REQENS |= (1 << 0); // Enable requests on line 0

    // EQUIVALENT CODE FOR N2HET INITIALIZATION
    //HET1REG->GCR |= ((1 << 24) | // Turn on the pins
	//	                 (1 << 17) | // Ignore suspen (TODO: See if this is needed or not...)
	//					 (1 << 16)); // Set to master mode (TODO: See if the is needed or not...)
	// Put the program into memory
	//memcpy((void *)&HET1RAM, (const void *)het1_instructions, sizeof(het1_instructions));
	//HET1REG->GCR |= (1 << 0); // Enable the N2HET1 peripheral
	n2het1_init(N2HET_PRGM);
    n2het2_init(N2HET_PRGM);
	

    while(1) {

    }

    return 0;
}

HET program (can't install the assembler on this computer, but I checked the HET1 program quite a few times and it seems that it's what it should be):

// Program for the N2HET1 peripheral
const het_memory_t het1_instructions[] = {
	{
		// Request number = 0, Next address = 1, Register = A
		// 000000 000 0 000000001 0110 0 00 0 0000 0
		// 0000 0000 0000 0000 0010 1100 0000 0000
		// Program
		0x00002C00,
		// Request type = General, max count = 0x270
		// 000 01 0 0 0000000000000001001110000
		// 0000 1000 0000 0000 0000 0010 0111 0000
		// Control
		0x08000270,
		// Data
		0x00000000,
		// Reserved
		0x00000000
	},
	
	{
		// Next address = 0, hr_lr = 0, Action pin enable = true, pin selec = 0, Action = Pulse high, 
		// Register = A, Compare value = 0xEA60
		// 000000 000 0 000000000 0000 0 0 0 0 000000
		// 0000 0000 0000 0000 0000 0000 0000 0000
		// Program
		0x00000000,
		// 000 00 0 000 1 000000000 00000 0 1 0 11 00 0
		// 0000 0000 0100 0000 0000 0000 0101 1000
		// Control
		0x00400058,
		// Data
		0x0000EA60,
		// Reserved
		0x00000000
	}
};
// Put the instruction memory and the instruction type defaults into a union
// This is more for convinience and ease of use. The instruction memory and
// program struct will take up the same memory space.
typedef union {
	het_memory_t instr_memory[HET1_LENGTH];
	struct {
		CNT L00;
		MCMP L01;
	} program_struct;
} het1_program;
// Actually instantiate the program
volatile het1_program het1_program_load;

Thanks

  • Hello Max,

    I will take a look at your code.

    Regards,
    QJ
  • Hello,

    1. To run the NHET microcode, you need to copy them into the NHET RAM using memcpy(..):

          memcpy((void *)&HET1RAM, (const void *)het1_instructions, sizeof(het1_instructions));

    2. In your HTU init, the destination address (NHET address) is defined as 24 (24 << 2) which means the program field of #7 instruction. But you have only 2 instructions (nhet1_instruction). Normally this address is the datafield of one instruction rather than the program field.

    If you want to transfer data from memory to data field of your 2nd instruction, the IHADDR should be: 0x6

    Regards,

    QJ

  • For the memcpy, I'm doing that in the n2het1_init and n2het2_init functions (have the equivalent code for the initialization function commented above the initializations). I have the initial program loading in just fine. When I put something else in, it changes as expected. It's the new value using the HTU that's not being transferred...

    Ok, I was a little confused on the addressing. Didn't know if it was addressing in bytes, words, or instruction length (the sine wave example is addressing with bytes, it seems. It has an N2HET address of 40). I want to say that I tried using a value of six, but I've tried so many configurations that I may not have tried it as is and an addressing of 0x6. I'll just change that and see if it works in the morning.

    Thanks
  • Hello Max,

    The initial NHET address (IHADDR, Bits 12:2) increments by one for each 32-bit NHET field and starts with zero at the first 32-bit field in the NHET RAM.

    I Just checked the sin_wave example, it writes 0x28 to bit[12:0], the IHADDR= 0xA.

    Regards,
    QJ
  • Oh, ok. That explains why they didn't shift by 2, then. Thought it was just a difference in bit assignment or something.

    I changed the address of 0x6, and it still doesn't seem to want to work.

    -Max