IAR debugging STM8S encountered the problem of wrong function return value

Publisher:SunshineHopeLatest update time:2022-05-09 Source: eefocusKeywords:IAR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The problem occurred when debugging EEPROM operation on stm8s003. I captured IIC communication data from the logic analyzer and saw that both reading and writing were normal. Under normal circumstances, a successful operation would directly return 0x00; but this time it always returned 0x37. Single-step tracing showed that the return was indeed 0, but after assigning the return value to a variable, it became 0x37. This driver has been used before without any problems, but I don't know why it's broken this time.


The IIC driver is in an independent C file, and the call is in another file, which is referenced through the extern declaration in the header file. After cross-comparison with the previous program, it was found that the function declaration in IIC.h was commented out, which is equivalent to calling it directly without declaration. Finally, after removing the comment, it returned to normal.


Keywords:IAR Reference address:IAR debugging STM8S encountered the problem of wrong function return value

Previous article:The problem of inaccurate time when using the STM8S timer for the first time
Next article:The same STM8 project generates inconsistent HEX checksums after changing the directory location

Recommended ReadingLatest update time:2024-11-15 07:25

Methods and precautions for using the standard firmware library of IAR for stm8
The standard library is actually quite convenient. With a template, if you change the parameters, you don't need to check the manual and redefine the register values. Part 1, introduction to the stm8 standard library. The standard library name code of stm8 is stsw-stm8069. According to this code, you can download th
[Microcontroller]
STM8S power consumption summary
STM8S103 STM8S003 Although the PA1 pin can wake up the CPU with an external interrupt, the power consumption is too large, with a current of 300uA, and it is not suitable for battery power supply. Therefore, do not use the external interrupt of PA1 to wake up the CPU. PA2 can be used, so in the sample board, I short-c
[Microcontroller]
STM8S power consumption summary
STM8S serial port application UART2 STM8S105
//Talk less and do more. The following is the serial port sending and receiving data that I have verified to be problem-free.   //Use MCU stm8s105c6 UART2      //Called during initialization:     GPIO_DeInit(GPIOD);     /* Configure PD5/6  */     GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_IN_PU_NO_IT); //Send data
[Microcontroller]
【STM8S】 Window watchdog
The .h file is as follows:     #ifndef __WWDG_H #define __WWDG_H #include "stm8s.h" void Delay();  void WWDG_Configuration(void) ;   void Refresh_WWDG_Window(void); #endif The .c file is as follows:   #include "wwdg.h" #include "stm8s_wwdg.h"   #define CounterInit 0x7f #define window      0x77   void Delay() //
[Microcontroller]
stm8s io configuration
The io registers of stm8s include DDR, IDR, ODR, CR1, and CR2. As for the configuration of io, you can understand it by reading the table below. The commonly used ones are push-pull output, floating input, and pull-up input. The following uses the PC1 pin as an example to explain how to configure these three modes.
[Microcontroller]
stm8s io configuration
Tips for STM32 MCUs: How to use IAR to develop STM32
BKP is not finished yet, why switch to RTC? Because RTC and BKP are somewhat related, it is impossible to separate them. The following is the introduction of RTC in the data sheet: Introduction to RTC The real-time clock is an independent timer. The RTC module has a set of counters that count continuously, and ca
[Power Management]
Tips for STM32 MCUs: How to use IAR to develop STM32
STM8S——Flash program memory and data EEPROM
1 Introduction   The FLASH program memory and data EEPROM inside STM8S are controlled by a set of general registers; so we can use these general registers to program or erase the memory contents, set write protection, or configure a specific low-power mode. We can also program the option byte of the device ourselves
[Microcontroller]
STM8S——Flash program memory and data EEPROM
FAQs about IAR Compilers
Recently, I started using IAR for AVR for a project. I used version 5.40, mainly because version 5.40 and above include aTtiny87. As for the installation files and harmony files, you can find them yourself, they are easy to find. 1. The compilation error is shown in the figure: Obviously you don't have the bit def
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号