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.
Hello
This is my next step, ( continuation of my previous post : CCS/TMS570LC4357: N2HEt HTU doesn't generate proper PWM. - Arm-based microcontrollers forum - Arm-based...
Right now I'm trying to generate 2 PWM's using HTU / DMA. Unfortunatelly only one PWM generate properly. The next one doesn't change the duty cycle.
Generally the background was the project SPNA217. "Sine Wave Generation Using PWM With HErcules"
1- Plot - NOT proper. PWM const. NHET Pin9
2 Plot proper, PWM change duty cycle. NHET Pin 4 (the plot isn't great but believe me in this case duty cycle is changing).
According to oscillogram. One PWM is working properly the next is not (PWM is const).
I've put the whole project in zip.
6012.Sine_wave_PWM2_TWO_PWMS.zip
Modified NHET code :
L00 CNT { reg=A,irq=OFF,max=PWM_PERIOD}; L01 ECMP {next=L01X,hr_lr=HIGH,en_pin_action=ON, cond_addr=L02, pin=PWM_PIN_NUM, action=PULSELO,reg=A,irq=OFF,data=INIT_COMPARE, hr_data=INIT_HR_DELAY}; L02 MOV32 { remote=L01,type=IMTOREG&REM,reg=NONE,data=INIT_COMPARE,hr_data=INIT_COMPARE}; L020 BR { next=L01X,reqnum=1,request=GENREQ,cond_addr=L01X,event=NOCOND}; L01X ECMP { next=L03,hr_lr=HIGH,en_pin_action=ON, cond_addr=L02X, pin=PWM_PIN_NUM2, action=PULSELO,reg=A,irq=OFF,data=INIT_COMPARE, hr_data=INIT_HR_DELAY}; L02X MOV32{ remote=L01X,type=IMTOREG&REM,reg=NONE,data=INIT_COMPARE,hr_data=INIT_COMPARE}; L021 BR { next=L03,reqnum=0,request=GENREQ,cond_addr=L03,event=NOCOND}; L03 BR { next=L00,cond_addr=L00,event=NOCOND};
Suspicious is, when I change "reqnum" to in L020 reqnum=0 and vice versa, L021 reqnum=1, then properly generated PWM are assigned to differ pins. But still only one PWM is capable to change duty cycle.
int main(void) { /* USER CODE BEGIN (3) */ htuInit(); //HTU !!! hetInit(); configNHET1(); while(1); return 0; } void configNHET1() { hetREG1->PFR = LRPFC << 8; calculate_ecmp_compare(); hetREG1->REQENS |= 0x3 ; // Request Enable Set Register (HETREQENS) Field Descriptions hetREG1->DIR = (1 << NHET1_PIN_PWM1) | (1 << NHET1_PIN_PWM2) ; hetRAM1->Instruction[pHET_L00_0].Control = (uint32)(CNT_MAX_PERIOD - 1) | (hetRAM1->Instruction[pHET_L00_0].Control & 0xFFFD0000); hetRAM1->Instruction[pHET_L01_0].Control = (hetRAM1->Instruction[pHET_L01_0].Control & 0xFFFFE0FF) | (NHET1_PIN_PWM1 << 8); hetRAM1->Instruction[pHET_L01X_0].Control = (hetRAM1->Instruction[pHET_L01X_0].Control & 0xFFFFE0FF) | (NHET1_PIN_PWM2 << 8); } void calculate_ecmp_compare() { int i=0; for (i=0;i<=SAMPLE_SIZE;i++) { sine_table[i] = (sine_table_percent[i] * (CNT_MAX_PERIOD << 7)); sine_table2[i] = (sine_table_percent2[i] * (CNT_MAX_PERIOD << 7)); } } void htuInit(void){ htuDCP1->ITCOUNT = 0x00010000 + SAMPLE_SIZE; htuDCP2->ITCOUNT = 0x00010000 + SAMPLE_SIZE; //for PWM2 htuDCP1->IHADDRCT = (htuDCP1->IHADDRCT & 0x0) | 0x1 << 23 | // DIR 0x0 << 22 | // SIZE 0x0 << 21 | // ADDMH 0x0 << 20 | // ADDFM 0x1 << 18 | // TMBA 0x0 << 16 | // TMBB 0x58; htuDCP2->IHADDRCT = (htuDCP2->IHADDRCT & 0x0) | 0x1 << 23 | // DIR 1 Main memory address is read and NHET address is written 0x0 << 22 | // SIZE 0 32-bit transfer 0x0 << 21 | // ADDMH 0 Increment by 16 bytes 0x0 << 20 | // ADDFM 0 Post-increment 0x1 << 18 | // TMBA 1h Circular buffer mode 0x0 << 16 | // TMBB 0 One Shot buffer mode 0x28; htuDCP1 -> IFADDRA = (unsigned int)sine_table; htuDCP2 -> IFADDRA = (unsigned int)sine_table2; htuREG1 ->CPENA = 0x00000001; htuREG1 ->GC = 0x00010000; // 16 HTUEN - 1 The Transfer Unit is enabled } /* USER CODE END */
Any suggestion what's wrong with this ?
Marcin.