From ca332e9ea1508fe30414f1e4efb16bb8c7655dfc Mon Sep 17 00:00:00 2001 From: yelvlab Date: Thu, 9 Jan 2025 15:48:50 +0800 Subject: [PATCH] debug --- inc/main.h | 1 + src/fwdgt.c | 2 +- src/main.c | 20 +++++++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/inc/main.h b/inc/main.h index 4df19ef..5e00524 100644 --- a/inc/main.h +++ b/inc/main.h @@ -44,6 +44,7 @@ OF SUCH DAMAGE. #include "fwdgt.h" #include "board_config.h" #include "gd60914.h" +#include "ultrasonic_analog.h" #ifdef SOFTWARE_IIC #include "soft_i2c.h" diff --git a/src/fwdgt.c b/src/fwdgt.c index 4beebce..688572f 100644 --- a/src/fwdgt.c +++ b/src/fwdgt.c @@ -15,7 +15,7 @@ void watchdog_init(void) { rcu_osci_stab_wait(RCU_IRC40K); /* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */ - fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz) + fwdgt_config(625, FWDGT_PSC_DIV256); // Set timeout to 1 seconds (625 / 0.625 KHz) /* Enable FWDGT */ fwdgt_enable(); diff --git a/src/main.c b/src/main.c index 023f270..1af7949 100644 --- a/src/main.c +++ b/src/main.c @@ -27,23 +27,29 @@ int main(void) /* configure FWDGT */ watchdog_init(); -#ifdef SOFTWARE_IIC - soft_i2c_config(); -#else - i2c_config(); -#endif +// #ifdef SOFTWARE_IIC +// soft_i2c_config(); +// #else +// i2c_config(); +// #endif printf("system start!\r\n"); ultrasonic_config(); while(1){ - gd60914_get_object_tempture(); + // gd60914_get_object_tempture(); - delay_ms(50); + delay_ms(500); ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES); + delay_ms(10); + + uint16_t distance = ultrasonic_calc_distance(); + + printf("%u\r\n", distance); + watchdog_reload(); } }