Event to port output avr 0-series

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

If I send an event to the EVOUT do I have control over whether it is setting or clearing the output? Can I also manipulate the output through the port register?

Every example I can find is sending events to trigger a2d but no simple output events.

I think I saw somewhere on the internet and example of this but I can't seem to find it now.

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

This is explained in the data sheet.
The PORT output operation is invalid, but the output direction seems to have to be set.

 

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

The port pinctrl invert bit controls whether you want a pin inverted, and I don't believe anything ever overrides that bit so you have complete control of input/output inversion. Once an EVOUT is enabled in portmux, you no longer can control the pin except for invert and pullup, so would need to disable evout for other manipulation although the invert bit can be used to change or set state (read pin, toggle invert if want the other state), and is quite a useful bit to have around. You will have to read in the datasheet about what a generator will output- pulse, level, etc., so an evout pin will simply follow what gets generated (some datasheets give more info than others).

 

I'm not an evsys expert, but this took a few minutes to test so it cannot be too hard to come up with your own tests.

 

//tiny817 Xplained, default 3.33MHz
#include <avr/io.h>
#include <stdbool.h>
#define F_CPU 3333333ul
#include <util/delay.h>

 

//PC0 = led, PC2 = EVOUT2, PC5 = asyncch2, manually toggle
//(manually toggle via invert bit) PC5 -> (evout2)PC2 -> manually set PC0 = PC2

 

static void led(bool tf){
    VPORTC.DIR |= PIN0_bm;
    if( tf ) VPORTC.OUT |= PIN0_bm; else VPORTC.OUT &= ~PIN0_bm;
}

 

int main(){
    EVSYS.ASYNCCH2 = EVSYS_ASYNCCH2_PORTC_PIN5_gc;     //PC5 generator
    EVSYS.ASYNCUSER10 = EVSYS_ASYNCUSER10_ASYNCCH2_gc; //EVOUT2 (PC2)
    PORTMUX.CTRLA |= PORTMUX_EVOUT2_bm;                //uses port DIR and OUT override

    for( uint16_t i = 0; ; i++ ){
        _delay_ms( 1 );
        if( 0 == (uint8_t)i ) PORTC.PIN5CTRL ^= (1<<7);//toggle invert every 256ms
        led( PORTC.IN & (1<<2) );                      //show EVOUT2 status (blinks at 2Hz)
    }
}

Last Edited: Thu. Mar 5, 2020 - 01:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks. I'll run some tests.