summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-06-17 08:38:42 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-06-17 15:08:31 +0800
commitdf3be3b3cb0ef947e58cd6b7f38f8ba3ac9fffae (patch)
treef859f6d4a40aa6627ff38f247d563e78ad982d88
parenta5e03524b0005c87bfda0e68b582cb06ba8ca8a1 (diff)
downloadfpm-door-lock-df3be3b3cb0ef947e58cd6b7f38f8ba3ac9fffae.tar.gz
Run at 3v3/8MHz.
-rw-r--r--Makefile3
-rw-r--r--README.txt5
-rw-r--r--main.c33
3 files changed, 21 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 883a3cf..8f22e14 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ CFLAGS += -Os
CFLAGS += -Wall
CFLAGS += -mmcu=$(MCU)
CFLAGS += -DBAUD=57600
-CFLAGS += -DF_CPU=16000000UL
+CFLAGS += -DF_CPU=8000000UL
CFLAGS += -DFPM_PWD=$(FPM_PWD)
CFLAGS += -ffunction-sections -fdata-sections
@@ -24,6 +24,7 @@ HEX_FLAGS += -j .text -j .data
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -c arduino
AVRDUDE_FLAGS += -P $(PORT)
+AVRDUDE_FLAGS += -b 57600
AVRDUDE_FLAGS += -D -U
%.o: %.c
diff --git a/README.txt b/README.txt
index 501c565..f0be804 100644
--- a/README.txt
+++ b/README.txt
@@ -33,9 +33,10 @@ LINEAR REGULATORS
3. When the ATmega328P is in power down mode, the MCU + linear regulators draw
13.7mA of quiescent current at 5.07V (without MOSFETS).
-BOOST CONVERTER
-
+MP1584EN BUCK CONVERTER
+ 1. When the system is in power down mode, the MCU + FPM + Servo draw 10.4mA at
+ 3.3V.
REMARKS
diff --git a/main.c b/main.c
index d495c3e..ba0c254 100644
--- a/main.c
+++ b/main.c
@@ -6,19 +6,19 @@
#include "fpm.h"
-#define SERVO_PIN PB1
-#define SERVO_DDR DDRB
+#define SERVO_PIN PB1
+#define SERVO_DDR DDRB
-#define PWM_MIN 500
-#define PWM_MID 1600
-#define PWM_MAX 2550
-#define PWM_TOP 20000
+#define PWM_MIN 500
+#define PWM_MID 1600
+#define PWM_MAX 2550
+#define PWM_TOP 19999
-#define VCC_MIN 4900
+#define VCC_MIN 4900
-#define LED_PIN PB5
-#define LED_DDR DDRB
-#define LED_PORT PORTB
+#define LED_PIN PB5
+#define LED_DDR DDRB
+#define LED_PORT PORTB
#define FRONT_UNLOCK_PIN PD2
#define FRONT_LOCK_PIN PD3
@@ -52,15 +52,13 @@ static volatile int cmd = NONE;
static inline void lock(void)
{
OCR1A = PWM_MID;
- _delay_ms(100);
- OCR1A = PWM_TOP;
+ _delay_ms(500);
}
static inline void unlock(void)
{
OCR1A = PWM_MAX;
- _delay_ms(100);
- OCR1A = PWM_TOP;
+ _delay_ms(500);
}
uint16_t getvcc(void)
@@ -125,10 +123,11 @@ int main(void)
(1 << BACK_LOCK_INT) | (1 << BACK_UNLOCK_INT));
/* servo */
+ TCCR1A |= (1 << WGM11);
+ TCCR1B |= (1 << WGM12) | (1 << WGM13);
+ TCCR1B |= (1 << CS11);
ICR1 = PWM_TOP;
- TCCR1A |= (1 << WGM11) | (1 << COM1A1);
- TCCR1B |= (1 << WGM13) | (1 << CS11);
-
+ TCCR1A |= (1 << COM1A1);
SERVO_DDR |= (1 << SERVO_PIN);
fpm_init();