add positive edge
This commit is contained in:
parent
c9b220616d
commit
8649d59d8d
@ -1,3 +1,5 @@
|
|||||||
|
#include <avr/ioavr128db48.h>
|
||||||
|
|
||||||
#include "fan_speeeed.h"
|
#include "fan_speeeed.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
@ -42,6 +44,36 @@ void PORTB_init() {
|
|||||||
PORTA.OUTSET |= PIN5_bm;
|
PORTA.OUTSET |= PIN5_bm;
|
||||||
PORTA.DIRSET |= PIN5_bm;
|
PORTA.DIRSET |= PIN5_bm;
|
||||||
}
|
}
|
||||||
|
// Voltage reference
|
||||||
|
#define VDACREF
|
||||||
|
#define VREF
|
||||||
|
#define DACREF_VALUE (VDACREF * 256 / VREF)
|
||||||
|
|
||||||
|
|
||||||
|
void init_ac(){
|
||||||
|
// CONFIGURE PINS AS ANALOG INPUTS
|
||||||
|
PORTD.PIN2CTRL = PORT_ISC_INPUT_DISABLE_gc;
|
||||||
|
|
||||||
|
// SET BENCH MARK
|
||||||
|
|
||||||
|
|
||||||
|
//SELECT POSITIVER INPUTS muxs
|
||||||
|
AC0.MUXCTRLA = AC_MUXPOS_AINP0_gc | AC_MUXNEG_DACREF_gc;
|
||||||
|
|
||||||
|
// OPTIONAL: ENABLE INNPUT PIN BY WRITING "1" TO OUTEN
|
||||||
|
AC0.CTRLA = 0x40; // 0b01000000
|
||||||
|
|
||||||
|
// ENABLE AC BY WRITING 1 TO ENABLE BIT IN ACN.CTRLA
|
||||||
|
AC0.CTRLA |= PIN0_bm; // 0b00000001
|
||||||
|
AC0.CTRLA = AC_ENABLE_bm | AC_INTMODE_NORMAL_POSEDGE_gc | AC_OUTEN_bm;
|
||||||
|
|
||||||
|
// SET CMP TO 1
|
||||||
|
AC0.INTCTRL = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(AC0_AC_vect){ // AC0 vec flag
|
||||||
|
AC0.STATUS |= 0x10; //CMP flag to 0.
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
//-------------------------------------- S E T U P-----------------------------------------------------
|
//-------------------------------------- S E T U P-----------------------------------------------------
|
||||||
|
|||||||
@ -38,6 +38,8 @@ int main(void) {
|
|||||||
|
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
|
PIN2_bm
|
||||||
|
|
||||||
/* Replace with your application code */
|
/* Replace with your application code */
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user