cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the download fail after changing the code in Keil?

Schuyler
Senior

 

  while (1)
  {
    /* Wake Up due to RTC timer */
    if(WakeUpTimerInterrupt) {
      WakeUpTimerInterrupt =0;
      WakeUpTimerCallBack();
    }
    
    /* There are a RF activity */
    if(RFActivity) {
      RFActivity = 0;
      DetectRFActivity();
    }
    
    /* There are a Async events */
    if (MemsInterrupt) {
      MemsInterrupt = 0;
      DetectMemsEvent();
    }

    /* Receive one interrupt from Timer */
    if((RFActivityStatus==FIELD_FALLING) | (ForceStart==1)) {
      if(ForceStart) {
        RFActivityStatus=FIELD_FALLING;
        ForceStart=0;
      }

      if( (ReadSensorAndLog & SYNC_EVENT ) ||
          (ReadSensorAndLog & ASYNC_EVENT) ) {
        if(NFCStatus == NFC_STATUS_OFF) {
          SmarTag_Deactivate_LPD();
          /* rise time required by NFC */
          HAL_Delay(10);
          NFCStatus = NFC_STATUS_ON;
        }

        SmarTag_LED_GREEN_On();

        if (NFC_EEPROM_Data.LogMode == SMARTAG_LOGMODE_INACTIVE) {
          /* Do Nothing */
          goto SMARTAG_SLEEP;
        }

        if (!NFC_EEPROM_Data.EnableFlags) {
          /* Do Nothing */
          goto SMARTAG_SLEEP;
        }

        /* beginning of Active log */
        if(ReadSensorAndLog & SYNC_EVENT) {
          /* Init SmarTag sensor */
          if(NFC_EEPROM_Data.LogMode != SMARTAG_LOGMODE_ACTIVE_THS) {
            InitSmarTagSensor();
          }
         /*MEMS_Sensors_ReadData();*/
					 /*SensorDataToCompactData();*/
					  K_Temperature=MAX6675_ReadTemperature(); 
					  sprintf(&temperaturebuffer[7], "Temperature: %.2f C", K_Temperature);
            SMARTAG1_NFCTAG_WriteData(Instance, (uint8_t *)temperaturebuffer, index, strlen(temperaturebuffer) + 1);
					

          /* DeInit SmarTag sensor */
          if(NFC_EEPROM_Data.LogMode != SMARTAG_LOGMODE_ACTIVE_THS) {
            DeInitSmarTagSensor();
          }

         
					
        }

        switch(NFC_EEPROM_Data.LogMode) {
        case SMARTAG_LOGMODE_ACTIVE:
            SMARTAG_PRINTF("-> Save Sync Event: ");
            ReadSensorAndLog &= ~SYNC_EVENT;
            ActiveLogWriteSyncAsynchronousEvents(0);
          break;
        case SMARTAG_SAVE_NEXT_SAMPLE:
            SMARTAG_PRINTF("-> Save Next Sample: ");
            ActiveLogWriteSyncAsynchronousEvents(0);
            /* Return to normal Active or Active with Th Log Mode */
            NFC_EEPROM_Data.LogMode = NFC_EEPROM_Data.PrevLogMode;
            /* Restore the combination of Enable flags for Previous LogMode */
            NFC_EEPROM_Data.EnableFlags = NFC_EEPROM_Data.PrevEnableFlags;
            /* This one should not be changed in theory... */
            NFC_EEPROM_Data.SampleIntervalSec = NFC_EEPROM_Data.PrevSampleIntervalSec;
            /* For overwriting the saved "Save next Sample" flag on NFC tag configuration */
            WriteConfiguration();
            
            if(NFC_EEPROM_Data.LogMode == SMARTAG_LOGMODE_ACTIVE_THS) {
              InitSmarTagSensor();
              InitAccEventThreshold();
            }
          break;
        case SMARTAG_LOGMODE_ACTIVE_THS:
            if(ReadSensorAndLog & ASYNC_EVENT) {
              ReadSensorAndLog &= ~ASYNC_EVENT;
              SMARTAG_PRINTF("Async Event Detected:\r\n");

              if ( EventStatus.D6DOrientationStatus != 0 ) {
                SmarTagSenValues.EventsDetected |= ACC_EVENT_6D_ORIENTATION;
                EventStatus.D6DOrientationStatus= 0;

                SMARTAG_PRINTF("\t6D Orientation= %d\r\n\tAccEventVmax= %d\r\n\r\n", SmarTagSenValues.SmarTagPosition, (SmarTagSenValues.AccEventVmax_6bit << 8));
              }

              if ( EventStatus.WakeUpStatus != 0 ) {
                SmarTagSenValues.EventsDetected |= ACC_EVENT_WAKE_UP;
                EventStatus.WakeUpStatus= 0;

                SMARTAG_PRINTF("\tWake up\r\n\tAccEventVmax= %d\r\n\r\n", (SmarTagSenValues.AccEventVmax_6bit << 8));
              }

              SMARTAG_PRINTF("-> Save Async Event: ");
              ActiveLogWriteSyncAsynchronousEvents(1);
            }

            if(ReadSensorAndLog & SYNC_EVENT) {
              ReadSensorAndLog &= ~SYNC_EVENT;
              if(((SmarTagSenValues.LPS22HBGood) &
                   ((SmarTagSenValues.LPS22HB_P_100xhPa    < SmarTagSenValues.P_Th_Min )   |
                    (SmarTagSenValues.LPS22HB_P_100xhPa    > SmarTagSenValues.P_Th_Max ))) |
                 ((SmarTagSenValues.HTS221Good ) &
                   ((SmarTagSenValues.HTS221_T_10xdegC     < SmarTagSenValues.T_Th_Min )  |
                    (SmarTagSenValues.HTS221_T_10xdegC     > SmarTagSenValues.T_Th_Max )  |
                    (SmarTagSenValues.HTS221_RH_10xpercent < SmarTagSenValues.RH_Th_Min)  | 
                    (SmarTagSenValues.HTS221_RH_10xpercent > SmarTagSenValues.RH_Th_Max)))) {
                SMARTAG_PRINTF("-> Save Sync Event with TH: ");
                ActiveLogWriteSyncAsynchronousEvents(0);
              }
            }
          break;
        }

        /* end of activelog */
SMARTAG_SLEEP:

        SmarTag_LED_GREEN_Off();
        if(NFCStatus == NFC_STATUS_ON) {
          SmarTag_Activate_LPD();
          NFCStatus = NFC_STATUS_OFF;
        }
      }
    }

#ifndef SMARTAG_ENABLE_DEBUG
    /* -> Stop mode */
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
#else /* SMARTAG_ENABLE_DEBUG */
      /* Wait Next event */
    __WFI();
#endif /* SMARTAG_ENABLE_DEBUG */
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

 

A burning error occurred when I changed the code of smartag1 to max6675 in MDK KEIL: Flash Timeout.Reset the Target and try it again.Above is my modification of the main function code.

[@EGG0)YPLK`$WUYL6F{@DJ.png

 

 

6 REPLIES 6
SofLit
ST Employee

Hello @Schuyler ,

It could be because you're using a low power mode.

Try to reset the MCU for a moment while connecting to it.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Is that the only information, or is there some other information in the logging window?

Suggest also going into the project settings and debug pane, and perhaps confirming or changing the connectivity settings there.

If you have a means to pull BOOT0 High on your board, perhaps try that also.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Schuyler
Senior

@SofLit 

Yes, I used the low-power mode, referring to the smartag1 sensor test function, but the code downloaded from the ST website worked fine.

Schuyler
Senior

Hi @Tesla DeLorean 

I used ST company's nucleo-L476RG to burn smartag1, but after I changed the code, I could not download successfully, and the above error occurred. I can't rule out whether the code is wrong, can you change the sensor to max6675?

What did you change in the code? you added low power mode or what?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Schuyler
Senior

Hi @SofLit 

I used the low power evaluation board STEVAL-SMARTAG1, and the main function for its reference code FP-SNS-SMARTAG1 was changed to the thermocouple sensor of max6675, whose code is given above.