Compare commits

...

1 Commits

Author SHA1 Message Date
ec50b15b2b change init func 2024-04-18 12:32:56 +02:00
4 changed files with 29 additions and 14 deletions

View File

@ -60,12 +60,17 @@ void PORT_init(){
EVSYS.CHANNEL0 = 0x40; EVSYS.CHANNEL0 = 0x40;
//EVSYS.SWEVENTA = 0x01; //EVSYS.SWEVENTA = 0x01;
EVSYS.USERTCB3CAPT = 0x01; EVSYS.USERTCB3CAPT = 0x01;
/* Zero-cross detector 0 out linked to event channel 0 */
EVSYS.CHANNEL0 = EVSYS_CHANNEL0_PORTA_PIN5_gc;
/* TCB uses event channel 0 */
//EVSYS.USERTCB0CAPT = EVSYS_USER_CHANNEL0_gc;
//RUNSTDBY disabled; CASCADE disabled; SYNCUPD disabled; CLKSEL DIV1; ENABLE enabled; //RUNSTDBY disabled; CASCADE disabled; SYNCUPD disabled; CLKSEL DIV1; ENABLE enabled;
TCB3.CTRLA = 0x01; TCB3.CTRLA = 0x01;
} }
void TCB0_Init(void){ void TCB0_Init(){
TCB3.CTRLB = TCB_CNTMODE_FRQPW_gc; /* Input Capture Frequency */ TCB3.CTRLB = TCB_CNTMODE_FRQPW_gc; /* Input Capture Frequency */
TCB3.EVCTRL = TCB_CAPTEI_bm; /* Event Input Enable: enabled */ TCB3.EVCTRL = TCB_CAPTEI_bm; /* Event Input Enable: enabled */
TCB3.EVCTRL |= (1 << TCB_CAPTEI_bp | 1 << TCB_EDGE_bp | 1 << TCB_FILTER_bp); /* Event Input Enable: enabled */ TCB3.EVCTRL |= (1 << TCB_CAPTEI_bp | 1 << TCB_EDGE_bp | 1 << TCB_FILTER_bp); /* Event Input Enable: enabled */
@ -74,15 +79,15 @@ void TCB0_Init(void){
| TCB_ENABLE_bm /* Enable: enabled */ | TCB_ENABLE_bm /* Enable: enabled */
| TCB_RUNSTDBY_bm; /* Run Standby: enabled */ | TCB_RUNSTDBY_bm; /* Run Standby: enabled */
} }
void EVSYS_Init(void) void EVSYS_Init()
{ {
/* Zero-cross detector 0 out linked to event channel 0 */ /* Zero-cross detector 0 out linked to event channel 0 */
EVSYS.CHANNEL0 = EVSYS_CHANNEL0_PORTA_PIN5_gc; // EVSYS.CHANNEL0 = EVSYS_CHANNEL0_PORTA_PIN5_gc;
/* TCB uses event channel 0 */ /* TCB uses event channel 0 */
EVSYS.USERTCB0CAPT = EVSYS_USER_CHANNEL0_gc; //EVSYS.USERTCB0CAPT = EVSYS_USER_CHANNEL0_gc;
} }
void PORT_Init(void) void PORT_Init1()
{ {
PORTB.OUTSET |= PIN5_bm; PORTB.OUTSET |= PIN5_bm;
PORTB.DIRSET |= PIN5_bm; PORTB.DIRSET |= PIN5_bm;

View File

@ -26,6 +26,10 @@ extern "C" {
void TCA0_init (); void TCA0_init ();
void PORT_init(); void PORT_init();
void TCB0_Init();
void PORT_init1();
void EVSYS_Init();
void TCA0_update_period_ms (); void TCA0_update_period_ms ();
uint16_t RPM_calculation(); uint16_t RPM_calculation();

View File

@ -29,13 +29,19 @@
int main() { int main() {
init_uart((uint16_t)9600); init_uart((uint16_t)9600);
stdout = &USART_stream; stdout = &USART_stream;
TCA0_init (); //TCA0_init ();
//PORT_init(); //PORT_init();
//test //test
TCB0_Init(); //TCB0_Init();
EVSYS_Init(); //EVSYS_Init();
PORT_Init(); //PORT_Init1();
TCA0_init ();
PORT_init();
//TCB0_Init();
PORT_init1();
//EVSYS_Init();
TCB3.INTCTRL = 0b00000001; // Bit 0 ? CAPT Capture Interrupt Enable TCB3.INTCTRL = 0b00000001; // Bit 0 ? CAPT Capture Interrupt Enable
sei(); sei();

View File

@ -4,10 +4,10 @@
<logicalFolder name="HeaderFiles" <logicalFolder name="HeaderFiles"
displayName="Header Files" displayName="Header Files"
projectFiles="true"> projectFiles="true">
<itemPath>uart.h</itemPath>
<itemPath>voltage.h</itemPath> <itemPath>voltage.h</itemPath>
<itemPath>fan_speeeed.h</itemPath> <itemPath>fan_speeeed.h</itemPath>
<itemPath>themistor-temp.h</itemPath> <itemPath>themistor-temp.h</itemPath>
<itemPath>uart.h</itemPath>
</logicalFolder> </logicalFolder>
<logicalFolder name="ExternalFiles" <logicalFolder name="ExternalFiles"
displayName="Important Files" displayName="Important Files"
@ -23,10 +23,10 @@
displayName="Source Files" displayName="Source Files"
projectFiles="true"> projectFiles="true">
<itemPath>main.c</itemPath> <itemPath>main.c</itemPath>
<itemPath>uart.c</itemPath>
<itemPath>voltage.c</itemPath> <itemPath>voltage.c</itemPath>
<itemPath>fan_speeeed.c</itemPath> <itemPath>fan_speeeed.c</itemPath>
<itemPath>thermistor-temp.c</itemPath> <itemPath>thermistor-temp.c</itemPath>
<itemPath>uart.c</itemPath>
</logicalFolder> </logicalFolder>
</logicalFolder> </logicalFolder>
<projectmakefile>Makefile</projectmakefile> <projectmakefile>Makefile</projectmakefile>