BAF concept , transmitting .elf file through CAN
Im using SPC58C80E5, working on Autodevkit studio,
#include "components.h"
#include "can_lld.h"
#include "can_lld_cfg.h"
#include "pal.h"
#include "osal.h"
/* Define your custom CAN packet ID for triggering the reset */
#define FLASH_RECOVERY_CAN_ID 0x7F0U
CANRxFrame rxmsg;
void HandleBootloaderRequest(void) {
/*
Check Mailbox 0 of CAND2 (which your working reference project proves
is the exact driver module tied to your physical PB9/PB10 pins).
*/
if (can_lld_receive(&CAND2, 0, &rxmsg) == CAN_MSG_OK) {
/* FIXED INVERTED LOGIC: pal_clearpad pulls pin LOW, turning LED 2 (PH4) ON */
pal_clearpad(PORT_H, 4U);
/*
MATCH VERIFICATION: Using the exact '.SID' layout and array index bracket
notation proven to execute successfully on your hardware bench.
*/
if (rxmsg.SID == FLASH_RECOVERY_CAN_ID && rxmsg.data8[0] == 0xAA) {
/* Cleanly disable system interrupts before register access */
irqIsrDisable();
/*
Trigger a Functional Software Reset via Direct Addressing.
Forces an immediate hardware core system reboot.
*/
*(volatile uint32_t *)(0xF402C000 + 0x18) = 0x00000001; // MC_RGM_FERR
*(volatile uint32_t *)(0xF402C000 + 0x20) = 0x00000000; // MC_RGM_FRET
*(volatile uint32_t *)(0xF402C000 + 0x30) = 0x5AF0; // MC_RGM_MODE
/* Infinite fallback trap loop while hardware registers process reboot */
while(1) {
asm("nop");
}
}
}
}
int main(void) {
/* AutoDevKit core initialization */
componentsInit();
/* Enable Interrupts using AutoDevKit's default global macro */
irqIsrEnable();
/* Start the physical module matching your working project configuration */
can_lld_start(&CAND2, &can_config_mcanconf);
/* Explicitly initialize your physical Port H LED pins as output channels */
pal_setpadmode(PORT_H, 1U, PAL_MODE_OUTPUT);
pal_setpadmode(PORT_H, 4U, PAL_MODE_OUTPUT);
/* FIXED INVERTED LOGIC: pal_setpad pulls pin HIGH, keeping LEDs turned OFF at startup */
pal_setpad(PORT_H, 1U);
pal_setpad(PORT_H, 4U);
/* Application main loop */
for ( ; ; ) {
/* Monitor the CAN bus continuously for incoming frames on CAND2 */
HandleBootloaderRequest();
/* Baseline Action: Toggle LED 1 (Port H Pin 1) to make it blink */
pal_togglepad(PORT_H, 1U);
/* Sleep delay using the AutoDevKit OSAL OS ticker */
osalThreadDelayMilliseconds(500);
}
}
first im executing this code LED is blinking after that when i send CAN message with ID 7F0 and data AA the LEDs becoming freeze if im resetting also they are in freeze, after that using SPC5 Flash programmer trying to flash the file but when i select the interface and click connect its loading not connecting, and also the port is not used by any other applications .
Im using ICP CON i-7530 as intermediate between PC and microcontroller to communicate with CAN . IN CAN im using PB[9] and PB[10] according to the SPC58EC user manual , check wt is happening please help with it.


