Skip to content

Commit bbeae75

Browse files
committedDec 2, 2017
Implemented timer functionality for delay purposes
1 parent 1390fa7 commit bbeae75

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
 

‎AstroKey.hwconf

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
1212
<property object="INTERRUPT_0" propertyId="ABPeripheral.included" value="true"/>
1313
<property object="INTERRUPT_0" propertyId="interrupt.interruptenable.enableallinterrupts" value="Enabled"/>
14+
<property object="INTERRUPT_0" propertyId="interrupt.interruptenable.enabletimer2interrupt" value="Enabled"/>
1415
<property object="INTERRUPT_0" propertyId="interruptenables.codegenerationoptions.generateinterruptfunctions" value="Disabled"/>
1516
<property object="P0.0" propertyId="ports.settings.label" value="S0"/>
1617
<property object="P0.0" propertyId="ports.settings.skip" value="Skipped"/>
@@ -28,6 +29,20 @@
2829
<property object="SPI_0" propertyId="spi.clockrate.sysclk" value="24.500 MHz"/>
2930
<property object="SPI_0" propertyId="spi.clockrate.sysclkdividercoefficientspi0ckr" value="7"/>
3031
<property object="SPI_0" propertyId="spi.control.slaveselectmode" value="Slave or master 3-wire mode"/>
32+
<property object="TIMER01_0" propertyId="ABPeripheral.included" value="true"/>
33+
<property object="TIMER16_2" propertyId="ABPeripheral.included" value="true"/>
34+
<property object="TIMER16_2" propertyId="timer16.control.runcontrol" value="Start"/>
35+
<property object="TIMER16_2" propertyId="timer16.control.timerrunningstate" value="Timer is Running"/>
36+
<property object="TIMER16_2" propertyId="timer16.highbyte.highbyte" value="240"/>
37+
<property object="TIMER16_2" propertyId="timer16.initandreloadvalue.targetoverflowfrequency" value="1000"/>
38+
<property object="TIMER16_2" propertyId="timer16.initandreloadvalue.timerinitvalue" value="61536"/>
39+
<property object="TIMER16_2" propertyId="timer16.initandreloadvalue.timerreloadvalue" value="61536"/>
40+
<property object="TIMER16_2" propertyId="timer16.lowbyte.lowbyte" value="96"/>
41+
<property object="TIMER16_2" propertyId="timer16.reloadhighbyte.reloadhighbyte" value="240"/>
42+
<property object="TIMER16_2" propertyId="timer16.reloadlowbyte.reloadlowbyte" value="96"/>
43+
<property object="TIMER16_3" propertyId="ABPeripheral.included" value="true"/>
44+
<property object="TIMER16_4" propertyId="ABPeripheral.included" value="true"/>
45+
<property object="TIMER_SETUP_0" propertyId="ABPeripheral.included" value="true"/>
3146
<property object="USBLIB_0" propertyId="ABPeripheral.included" value="true"/>
3247
<property object="USBLIB_0" propertyId="configuration.configurationparameters.configurationstring" value=""/>
3348
<property object="USBLIB_0" propertyId="configuration.configurationparameters.devicepower" value="Bus-Powered"/>

‎inc/delay.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* delay.h
3+
*
4+
* Created on: Dec 2, 2017
5+
* Author: Aaron
6+
*/
7+
8+
#ifndef INC_DELAY_H_
9+
#define INC_DELAY_H_
10+
11+
#include <stdint.h>
12+
13+
uint32_t getMillis();
14+
void resetMillis();
15+
16+
#endif /* INC_DELAY_H_ */

‎src/delay.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "SI_EFM8UB1_Register_Enums.h"
2+
#include "delay.h"
3+
4+
static volatile uint32_t millis = 0;
5+
6+
uint32_t getMillis()
7+
{
8+
return millis;
9+
}
10+
11+
void resetMillis()
12+
{
13+
millis = 0;
14+
}
15+
16+
SI_INTERRUPT(timer2ISR, TIMER2_IRQn)
17+
{
18+
// Increment millisecond counter
19+
millis++;
20+
// Clear interrupt flag
21+
TMR2CN0 &= ~(TMR2CN0_TF2H__SET | TMR2CN0_TF2L__SET);
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.