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