atxmega awex advanced waveform extension

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Has anyone used this feature?

Its not making sense to me....I am trying to get my PWM generated for CC0A to be pumped through all the 6 pins (AH, AL, BH, BL, CH and CL).

I do setup my timer as follows:

PWM_TIMER->CTRLB  = TC_WG_SS | TC0_CCAEN_bm;
PWM_TIMER->PER = PWM_TOP_VALUE;
PWM_TIMER->CCA = duty;

AWEX->CTRL = AWEX_PGM_bm | AWEX_CWCM_bm;
AWEX->OUTOVEN = 0x3F;  //enable override on all 6 pins
AWEX->DTHS = 0x3F;     //out through all pins for testing

PWM_TIMER->CTRLA = TC_CLKSEL_DIV1_gc;  //run timer with prescaler of 1.

The thing is I can only see waveform on my oscilloscope via CCA pin and none other of the 6 pins.... :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

https://www.avrfreaks.net/index.p...

this is interesting!!!
I am going to try it...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok this is my understanding so far....

//enable the clocking of timers 0 on PORTC
	sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC0);
	sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_HIRES);
		
	//setup timer 0 on PORTC for PWM generation using AWEX
	PWM_TIMER->CTRLB  = TC_WG_SS;				//single slope operation						
	PWM_TIMER->PER    = PWM_TOP_VALUE;			//fixed freq PWM
	Speed = 20;
	PWM_TIMER->CCA = Speed;						//ON time, initialize with 0
	
	//setup the advanced waveform extension ports
	AWEX->CTRL = AWEX_PGM_bm		|			//PGM = pattern generator mode
				 //AWEX_CWCM_bm		|			//all channels to have same waveform as CCA channel PWM (should not be used when PGM is set)
				 AWEX_DTICCAEN_bm	|			//need to enable this for PGM to work
				 AWEX_DTICCBEN_bm	|			//need to enable this for PGM to work
				 AWEX_DTICCCEN_bm;				//need to enable this for PGM to work
	//only using AH, AL, BH, BL, CH and CL pins in PORTC
	//Patter generator uses DTI High byte and Low byte
	//The High byte holds the port pin state (On or off). And
	//Low side selects which one should have output override enabled.
	//I need a selected pin to PWM and the unselected pin to be LOW.
	//Best to use DTBOTHBUFF as this will update both High and Low bytes
	//This way selected pins will be PWMed and the unselected PINs will remain LOW
	AWEX->DTBOTHBUF = COMMUT_PIN_MASK;		//testing with all pins
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AWEX is designed to output waveforms from CCA-CCD , normally the timer, e.g. TCC0 does run in normal mode and the CC registers then control the resp. pins ( CCA for UH and UL, CCB for VH and VL ) and so on. To make the pins carry the AWEX output don't forget to set

AWEXC.OUTOVEN = 0x3f ;

This will route CCA to CCC to the output pins.
Pattern generator mode is different. I'm not using it but from what i read the DTI registers take over the generation of the PWM. In my application i need to switch seamlessly between block commutation and 3 phase sine wave so i decided to use the traditional method ( switching pins to input according to the pattern) for block and then the AWEX for sine generation as that is much faster.