Close

CAN We do it? yes we CAN

A project log for OM127-reboot

repair currupt firmware system in OM127 OBD2 scanner from AUTOPHIX

darkspr1tedarkspr1te 05/24/2018 at 17:460 Comments

So lets talk a bit about the CAN side, The can chip is a NXP TJA1050 SO8 , quite simple pin out, apart from usual power there is can High/LOW, TX & RX and mute , oh one other is voltage ref out but thats not a function concern as were are not designing the system, just using it. So we have 5 pins for it's operation, our uarts TX & RX which is the low side or MCU side and CAN High/Low which is vehicle side or hot side (Pin 6 & 15 OBD)

Last pin of the can chip is the mute control, this is to stop devices putting noise on the system when starting up, you have this pin tied to 3.3v via a resistor and it will mute the chip at power on until your MCU bring it low for comms, in this case our STM32F103's SWD pin PA13 is tied to the Mute control and during normal debugging PA13 is always high, Now of course we did not know this and proceeded to lift PIN8 (Silent) and connect it to a unused pin PA8, which on different devices connect to a transistor, resistor and finally a little speaker. In our board photo's you will see I've hijacked PA8 to be my CAN mute control and my PIN13 led, I'am not bothed about introducing some random characters just yet so pin is not tied high but goes via a resistor and led to 3.3v, so when led is on I am TX'ing although you will notic i dont shut it off that often in the source code, We still have to tidy up a lot of functions to become usable, in fact this may be reworked into a new app totaly and only use part of the code, the original github om127-reboot was to get the board going, a final application for the device might be a start from scratch now that we know what 'ahem' we are doing. 

Did i mention that annoying bit about PA13 being high all the time, "cue afroman" , well the cure is to issue 

afio_cfg_debug_ports(AFIO_DEBUG_NONE);

 But a word of warning here, one the above has been called then you cannot reflash using stmlink without doing some other things first,

You can reactivate the STLINK/SWD port on pins PA13/PA15 buy calling the following ,

afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ);

also indecently , calling  

afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY);

will keep PA13 as SWD and allow the STLINK to trigger debug, this switches PA15 back to SWDCLK from being a gpio which DEBUG_NONE or DEBUG_FULL_SWJ will trigger.

So what have we learned kids ? 

yes thats right, I locked myself out of my STM32F,

ah well, stay tuned for tomorrow's new school old project, bReaking bAck 

darkspr1te

Discussions