This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

App doesn't start occasionally

Good day to everybody!

My device has C8051F340 MCU on board. I have project that is strange. E.g 5 times app starts - on 6th time it doesn't and so on.

Project architecture is Bootloader + App:
Bootloader's BLMisc:
CODE(0x0-0x05FF, 0xF200-0xF3FF, 0xFA00-0xFBFE, ?CO?FXXX_TARGETBL_INFOBLOCK(0xFBEC))

App's BL51 Misc:
CODE(0x0600-0xF1FF, 0xF400-0xF9FF, ?CO?I_SETTINGS(0xF500), ?CO?R_SETTINGS(0xF600), ?CO?FXXX_INFOBLOCK(0xF9E7))

App's C51:
INTVECTOR(0x0600) INTERVAL(3)

Keil version V4.14.16.0.

Behavior:
I can check leds and control points to understand whether it behaves right or not.
The previous version of project works stable. Then I start to remove uncalled functions not changing the logic much. Of course the new map file is linked differently but may be that is why it works bad. I feel that because of settings.

Any ideas? Thanks in advance!

Best regards,
Sergey Nelyub

  • how do you get to the apps interrupts (and reset vector)?

  • When reset the program enters bootloader and if some conditions are correct (signature check passed) we enter App. In bootloader project modified startup.a51 file I have the interrupts redirection to app:

    HW_INTVEC_TABLE       EQU 0003h     ;HW Interrupt vector table starts here
    HW_INTVEC_SEPARATION  EQU 8         ;HW Interrupt vector separation is 8 Bytes
    
    PUBLIC START_APPLICATION            ;The entry point (relocated reset vector)
    START_APPLICATION     EQU  0600     ;for the application FW project
    
    INTVEC_TABLE          EQU  START_APPLICATION+3  ;Interrupt vector table starts here
    INTVEC_SEPARATION     EQU  3        ;Interrupt vector separation is 3 Bytes
    
          CSEG  AT HW_INTVEC_TABLE + (HW_INTVEC_SEPARATION * 0)  ;03h (Intr. 00)
          AJMP  INTVEC_TABLE + (INTVEC_SEPARATION * 0)
    
          CSEG  AT HW_INTVEC_TABLE + (HW_INTVEC_SEPARATION * 1)  ;0Bh (Intr. 01)
          AJMP  INTVEC_TABLE + (INTVEC_SEPARATION * 1)
    
          // ...
    
          CSEG  AT HW_INTVEC_TABLE + (HW_INTVEC_SEPARATION * 16) ;83h (Intr. 16)
          AJMP  INTVEC_TABLE + (INTVEC_SEPARATION * 16)
    
    

    E.g. If timer2 overflows interrupt 5 occurs:
    Bootloader Addr Code Space: App Addr Code Space:
    0x002B->LJMP (0x0603 + (3*5)) ----> LJMP (Timer2_ISR)->Timer2_ISR

  • OK, when it 'does not start' does the booter start

  • with the '340 you have full debug, does it always start in debug?

  • In Bootloader I have the 3 control points too. If the program doesn't start the App for some reason and stays in Bootloader instead I could check them. They should be '0', '1' and toggling correspondingly but they are different. That's why I suggest that the program hasn't started at all in this case.

  • I have several dozens of identical devices that I switch on at once. So it's rather difficult to 'catch the bug' in the debug mode because it's unclear what device will misbehave. I could only connect USB Debug Adapter to one of them.