Compare commits
2 Commits
58014e17d1
...
57a35a483d
| Author | SHA1 | Date | |
|---|---|---|---|
| 57a35a483d | |||
| abc13364ec |
@ -24,10 +24,12 @@ uint16_t RPM_calculation() {
|
|||||||
|
|
||||||
void PORT_init(){
|
void PORT_init(){
|
||||||
//compare or capture
|
//compare or capture
|
||||||
TCB3.CCMP = 0x00;
|
//TCB3.CCMP = 0x00;
|
||||||
//count
|
//count
|
||||||
TCB3.CNT = 0x00;
|
TCB3.CNT = 0x00;
|
||||||
|
|
||||||
|
PORTA.IN = PIN0_bm;
|
||||||
|
PORTA.PIN0CTRL = PORT_PULLUPEN_bm;
|
||||||
|
|
||||||
//PORTD.PIN2CTRL = PORT_ISC_FALLING_gc | 0b01000000;
|
//PORTD.PIN2CTRL = PORT_ISC_FALLING_gc | 0b01000000;
|
||||||
// TCB3.CTRLB =0<< TCB_ASYNC_bp /* Asynchronous Enable: disabled */|0<< TCB_CCMPEN_bp /* Pin Output Enable: disabled */|0<< TCB_CCMPINIT_bp /* Pin Initial State: disabled */| TCB_CNTMODE_FRQ_gc;/* Input Capture Frequency measurement */
|
// TCB3.CTRLB =0<< TCB_ASYNC_bp /* Asynchronous Enable: disabled */|0<< TCB_CCMPEN_bp /* Pin Output Enable: disabled */|0<< TCB_CCMPINIT_bp /* Pin Initial State: disabled */| TCB_CNTMODE_FRQ_gc;/* Input Capture Frequency measurement */
|
||||||
@ -36,30 +38,31 @@ void PORT_init(){
|
|||||||
// TCB3.CTRLA = TCB_CLKSEL_DIV1_gc /* CLK_PER */|1<< TCB_ENABLE_bp /* Enable: enabled */|0<< TCB_RUNSTDBY_bp /* Run Standby: disabled */|0<< TCB_SYNCUPD_bp /* Synchronize Update: disabled */|0<< TCB_CASCADE_bp;/* Cascade Two Timer/Counters: disabled */
|
// TCB3.CTRLA = TCB_CLKSEL_DIV1_gc /* CLK_PER */|1<< TCB_ENABLE_bp /* Enable: enabled */|0<< TCB_RUNSTDBY_bp /* Run Standby: disabled */|0<< TCB_SYNCUPD_bp /* Synchronize Update: disabled */|0<< TCB_CASCADE_bp;/* Cascade Two Timer/Counters: disabled */
|
||||||
|
|
||||||
//ASYNC disabled; CCMPINIT disabled; CCMPEN disabled; CNTMODE FRQPW;
|
//ASYNC disabled; CCMPINIT disabled; CCMPEN disabled; CNTMODE FRQPW;
|
||||||
TCB3.CTRLB = 0x15;
|
TCB3.CTRLB = 0x04;
|
||||||
|
|
||||||
//DBGRUN disabled;
|
//DBGRUN disabled;
|
||||||
TCB3.DBGCTRL = 0x00;
|
//TCB3.DBGCTRL = 0x00;
|
||||||
|
|
||||||
//FILTER disabled; EDGE disabled; CAPTEI enabled;
|
//FILTER disabled; EDGE disabled; CAPTEI enabled;
|
||||||
TCB3.EVCTRL = 0x01;
|
TCB3.EVCTRL = 0x01;
|
||||||
|
|
||||||
//OVF disabled; CAPT enabled;
|
//OVF disabled; CAPT enabled;
|
||||||
TCB3.INTCTRL = 0x03;
|
TCB3.INTCTRL = 0x01;
|
||||||
|
|
||||||
//OVF disabled; CAPT disabled;
|
//OVF disabledAPT disabled;
|
||||||
TCB3.INTFLAGS = 0x00;
|
//TCB3.INTFLAGS = 0; CAPT disabled;
|
||||||
|
//TCB3.INTFLAGS = 0x00;
|
||||||
|
|
||||||
//Temporary Value
|
//Temporary Value
|
||||||
TCB3.TEMP = 0x00;
|
//TCB3.TEMP = 0x00;
|
||||||
|
|
||||||
//RUNSTDBY disabled; CASCADE disabled; SYNCUPD disabled; CLKSEL DIV1; ENABLE enabled;
|
|
||||||
TCB3.CTRLA = 0x01;
|
|
||||||
|
|
||||||
EVSYS.CHANNEL0 = 0x48 + 0x05;
|
EVSYS.CHANNEL0 = 0x40;
|
||||||
EVSYS.SWEVENTA = 0x01;
|
//EVSYS.SWEVENTA = 0x01;
|
||||||
EVSYS.USERTCB3CAPT = 0x01;
|
EVSYS.USERTCB3CAPT = 0x01;
|
||||||
|
|
||||||
|
//RUNSTDBY disabled; CASCADE disabled; SYNCUPD disabled; CLKSEL DIV1; ENABLE enabled;
|
||||||
|
TCB3.CTRLA = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCB0_Init(void){
|
void TCB0_Init(void){
|
||||||
@ -97,15 +100,17 @@ ISR ( TCA0_OVF_vect ) {
|
|||||||
sei();
|
sei();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
void printnie(uint8_t en, uint8_t to){
|
||||||
|
printf("CNT %u", en);
|
||||||
|
printf("ccmp %u", to);
|
||||||
|
}
|
||||||
|
|
||||||
ISR (TCB3_INT_vect){
|
ISR (TCB3_INT_vect){
|
||||||
uint16_t yo = TCB3.CNT;
|
uint16_t yo = TCB3.CNT;
|
||||||
printf("CNT %u", yo);
|
|
||||||
|
|
||||||
printf("too");
|
|
||||||
|
|
||||||
uint16_t stewui = TCB3.CCMP;
|
uint16_t stewui = TCB3.CCMP;
|
||||||
printf("CCMP %u", stewui);
|
|
||||||
|
|
||||||
|
printnie(yo, stewui);
|
||||||
TCB3.INTFLAGS = 0x03;
|
TCB3.INTFLAGS = 0x03;
|
||||||
//TCB3.INTFLAGS = PIN0_bm;
|
//TCB3.INTFLAGS = PIN0_bm;
|
||||||
|
|
||||||
|
|||||||
@ -41,13 +41,25 @@ int main() {
|
|||||||
sei();
|
sei();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
/*
|
||||||
//printf("loop");
|
printf("loop");
|
||||||
//uint16_t yo = TCB3.CNT;
|
uint16_t yo = TCB3.CNT;
|
||||||
//printf("CNT %u", yo);
|
printf("CNT %u", yo);
|
||||||
|
uint16_t stewui = TCB3.CCMP;
|
||||||
//uint16_t stewui = TCB3.CCMP;
|
printf("CCMP %u", stewui);
|
||||||
//printf("CCMP %u", stewui)
|
*/
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*ISR (TCB3_INT_vect){
|
||||||
|
uint16_t yo = TCB3.CNT;
|
||||||
|
printf("CNT %u", yo);
|
||||||
|
|
||||||
|
uint16_t stewui = TCB3.CCMP;
|
||||||
|
printf("CCMP %u", stewui);
|
||||||
|
|
||||||
|
TCB3.INTFLAGS = 0x03;
|
||||||
|
//TCB3.INTFLAGS = PIN0_bm;
|
||||||
|
|
||||||
|
}*/
|
||||||
Loading…
Reference in New Issue
Block a user