diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-10-23 19:44:16 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-10-23 19:44:16 -0400 |
| commit | 94cdc9ec4e75fc5e55deb394eda4820ba672e3e4 (patch) | |
| tree | cf0762794d78324cd508cf5e80b5a13351965d63 /fw | |
| parent | 04fbfdb4fd6bf4118b88867d852e3b29d139c800 (diff) | |
| download | can-gauge-interface-94cdc9ec4e75fc5e55deb394eda4820ba672e3e4.zip | |
enable CLKOUT
Diffstat (limited to 'fw')
| -rw-r--r-- | fw/can.c | 7 | ||||
| -rw-r--r-- | fw/system.c | 2 | ||||
| -rw-r--r-- | fw/tests/system/can_tx_systest.c | 2 |
3 files changed, 7 insertions, 4 deletions
@@ -12,6 +12,8 @@ // Oscillator startup timeout #define STARTUP_TIME 128u +#define TX_RETRIES 10u + // Register addresses typedef enum { // Config and status @@ -288,6 +290,7 @@ canTx(const CanFrame *frame) { // Send bitModify(REG_TXB0CTRL, TXREQ, TXREQ); + k = 0u; do { ctrl = read(REG_TXB0CTRL); if (ctrl & TXERR) { @@ -295,9 +298,9 @@ canTx(const CanFrame *frame) { bitModify(REG_TXB0CTRL, TXREQ, 0); // cancel transmission return FAIL; } - } while (ctrl & TXREQ); // transmission in progress + } while ((ctrl & TXREQ) && (++k <= TX_RETRIES)); // transmission in progress - return OK; + return (k <= TX_RETRIES) ? OK : FAIL; } void diff --git a/fw/system.c b/fw/system.c index 720f456..5f7bbb4 100644 --- a/fw/system.c +++ b/fw/system.c @@ -9,7 +9,7 @@ #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR pin is MCLR) #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled) #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled) -#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin) +#pragma config CLKOUTEN = ON // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin) #pragma config IESO = OFF // Internal/External Switchover Mode (Internal/External Switchover Mode is disabled) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled) diff --git a/fw/tests/system/can_tx_systest.c b/fw/tests/system/can_tx_systest.c index a770d06..b1dec17 100644 --- a/fw/tests/system/can_tx_systest.c +++ b/fw/tests/system/can_tx_systest.c @@ -49,7 +49,7 @@ main(void) { void __interrupt() isr(void) { if (PIR1bits.TMR1IF) { - if (++ctr == 23u) { // 1s period + if (++ctr == 114u) { // 5s period (void)canTx(&frame); ctr = 0u; } |