
-Matt
Code: Select all
//Base clock is HSE/128 = 8MHz/128 = 62.5kHz
//62.5kHz / (624 + 1) = 100Hz
rtc_auto_awake(RCC_HSE, 624); //10ms tick
Code: Select all
void rtc_auto_awake(enum rcc_osc clock_source, uint32_t prescale_val)
{
uint32_t reg32;
/* Enable power and backup interface clocks. */
rcc_periph_clock_enable(RCC_PWR);
rcc_periph_clock_enable(RCC_BKP);
reg32 = rcc_rtc_clock_enabled_flag();
if (reg32 != 0) {
rtc_awake_from_standby();
} else {
rtc_awake_from_off(clock_source);
rtc_set_prescale_val(prescale_val);
}
}
Thanks johu, useful for an overall view to make sure it's going about the same thing.johu wrote: ↑Thu Oct 22, 2020 9:05 pm Heres the code I use for the F1:
...
From here: https://github.com/jsphuebner/libopencm ... 2/f1/rtc.c
Maybe it helps.
Let me play with it a little before waving a white flag. Worst case we can use the DS2321M. What STM32 based boards do you have? I'll try and rig something up to send to you for use with your data capture attempts.
Code: Select all
mdrobnak@dell-cp2-md-ubuntu:~/redact$ cargo build --features=nucleo767zi
warning: file found to be present in multiple build targets: /home/mdrobnak/redact/src/main.rs
Updating git repository `https://github.com/mdrobnak/stm32f7xx-hal.git`
Compiling stm32f7xx-hal v0.2.0 (https://github.com/mdrobnak/stm32f7xx-hal.git#1ff6c666)
Compiling cpcontrol v0.1.0 (/home/mdrobnak/redact)
Finished dev [unoptimized + debuginfo] target(s) in 12.70s
mdrobnak@dell-cp2-md-ubuntu:~/redact$ cargo build --features=f4board
warning: file found to be present in multiple build targets: /home/mdrobnak/redact/src/main.rs
Compiling stm32f4 v0.11.0
Compiling stm32f7 v0.11.0
Compiling rand_core v0.5.1
Compiling cpcontrol v0.1.0 (/home/mdrobnak/redact)
Compiling embedded-dma v0.1.2
Compiling stm32f4xx-hal v0.8.3 (https://github.com/mdrobnak/stm32f4xx-hal.git#845f1902)
Finished dev [unoptimized + debuginfo] target(s) in 24.43s
mdrobnak@dell-cp2-md-ubuntu:~/redact$ ls -l target/thumbv7em-none-eabihf/debug/cpcontrol-f?
-rwxrwxr-x 2 mdrobnak mdrobnak 2860132 Oct 22 23:30 target/thumbv7em-none-eabihf/debug/cpcontrol-f4
-rwxrwxr-x 2 mdrobnak mdrobnak 3238296 Oct 22 23:29 target/thumbv7em-none-eabihf/debug/cpcontrol-f7
Code: Select all
mdrobnak@dell-cp2-md-ubuntu:~/redact$ git diff src/two_fifty_ms_loop.rs
diff --git a/src/two_fifty_ms_loop.rs b/src/two_fifty_ms_loop.rs
index 76d73a0..f4500e7 100644
--- a/src/two_fifty_ms_loop.rs
+++ b/src/two_fifty_ms_loop.rs
@@ -1,7 +1,6 @@
#![deny(warnings)]
-extern crate stm32f7xx_hal as hal;
use crate::types::HVCAN;
-use hal::can::{BaseID, DataFrame, ID};
+use crate::types::{BaseID, DataFrame, ID};
use heapless::consts::*;
use heapless::String;
Sorry I've been slacking off on this project:)mdrobnak wrote: ↑Tue Oct 20, 2020 5:41 am Overall looks good. I'm just going to jot down some thoughts under here. I may ask some stupid questions. Please be patient.
We're substituting the STLink USB passthrough for a dedicated USB, yes? What are the LEDs for on the USB connection? Mini USB is good.
CAN connections look good. I need to try PA11/12 again. I tried that before I had the timing right on the F4 board and got nowhere.
Power supply is interesting - I don't think I've ever seen 0.1uF next to a 470 uF cap. What's the purpose of that?
What's the EEPROM actually connected to? SCL and SDA are connected to the CPU with a 4.7kOhm pull-up to 3.3V?
Latch output works fine with high side drive straight off the CPU on the Nucleo board (so 3.3V), I was driving it with the SimpBMS' 5V output, so your 5V output should work great there.
Proximity voltage is 12V I think, so good call on the digital inputs being 12V capable.
Fault line worked fine on a standard digital input on my F7 board. So, to ADC or to GPIO?I'm also not sure of the RC value on the input. They have the schematics here - https://www.st.com/resource/en/schemati ... ns_sch.zip - Board is MB1137 / Nucleo-F767ZI - I'm using PG2 for the fault input and PG3 for the latch output.
8MHz and 32,768Hz crystals look great.
The layout I can't say much as I've done single layer PCBs but never more than that. Silkscreen layer looks good.
So I don't think there are any changes, subject to your thoughts based on my feedback. (If read it right, the ADC input can also be used in digital mode as well - but may not work as well with the resistor...hence I am deferring to you on this.)
Bed time now.
-Matt
Sorry I missed that. Yeah I put a serial to usb on Serial 1. The leds are just tx , rx indicators for the serial.mdrobnak wrote: ↑Sun Oct 25, 2020 9:30 am
To reiterate other questions:
We're substituting the STLink USB passthrough for a dedicated USB, yes? What are the LEDs for on the USB connection? Mini USB is good.
CAN connections look good. I need to try PA11/12 again. I tried that before I had the timing right on the F4 board and got nowhere.
What's the EEPROM actually connected to? SCL and SDA are connected to the CPU with a 4.7kOhm pull-up to 3.3V?
It's late. Bed time for real. Got a lot done today though!
-Matt
No worries. Ok, activity LEDs, got it.Jack Bauer wrote: ↑Sun Oct 25, 2020 10:43 am Sorry I missed that. Yeah I put a serial to usb on Serial 1. The leds are just tx , rx indicators for the serial.
SDA and SCL are on PB7 and PB6. I got those pins from using CubeMX as the I2c pins. Is that ok?
Finally got the setup on the bench and shot some log files.
https://github.com/damienmaguire/Tesla- ... Controller
I couldn't help but peek.
Code: Select all
mdrobnak@dell-cp2-md-ubuntu:~/vcs/git/mdrobnak-stm32f4xx-hal/src$ diff ../../mdrobnak-stm32f7xx-hal/src/rtc.rs rtc.rs
440c440
< pwr.cr1.modify(|_, w| {
---
> pwr.cr.modify(|_, w| {
The RTC init code did end up being very similar as seen here - https://github.com/mdrobnak/stm32f7xx-h ... 066dc499c5johu wrote: ↑Thu Oct 22, 2020 9:05 pm Heres the code I use for the F1:
Which expands to:Code: Select all
//Base clock is HSE/128 = 8MHz/128 = 62.5kHz //62.5kHz / (624 + 1) = 100Hz rtc_auto_awake(RCC_HSE, 624); //10ms tick
From here: https://github.com/jsphuebner/libopencm ... 2/f1/rtc.cCode: Select all
void rtc_auto_awake(enum rcc_osc clock_source, uint32_t prescale_val) { uint32_t reg32; /* Enable power and backup interface clocks. */ rcc_periph_clock_enable(RCC_PWR); rcc_periph_clock_enable(RCC_BKP); reg32 = rcc_rtc_clock_enabled_flag(); if (reg32 != 0) { rtc_awake_from_standby(); } else { rtc_awake_from_off(clock_source); rtc_set_prescale_val(prescale_val); } }
Maybe it helps.
Code: Select all
// Steps:
// Enable PWR and DBP
// Enable LSE (if needed)
// Enable RTC Clock
// Disable Write Protect
// Enter Init
// Configure 24 hour format
// Set prescalers
// Exit Init
// Enable write protect
This is generated by the CP ECU, not directly from the input, as far as I can tell. I think it's used for drive away protection.
Code: Select all
for(int i=0;i<9;i++)