Use of OptionByte of stm8

Publisher:云自南国来Latest update time:2018-05-20 Source: eefocusKeywords:stm8  OptionByte Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. The concept of option bytes (refer to stm8s Chinese data sheet):

The option bytes include the configuration of the chip hardware features and the protection information of the memory. These bytes are stored in a dedicated
block in the memory. In addition to the ROP (read-out protection) byte, each option byte must be saved twice, one in the usual format (OPTx) and
one in the complementary format (NOPTx) for backup. The option bytes can be modified in ICP mode (via SWIM) by accessing the EEPROM address in the table below.
The option bytes can also be modified by the application in IAP mode, but the ROP option can only be
modified in ICP mode (via SWIM).

2. The concept of ISP IAP ICP (to be learned):

  ISP: In System Programing, In System Programming Program is fully downloaded

  IAP: In applicating Programing, in application programming, my understanding is to use the application to modify some fixed data in the chip (data not related to application programming)

  ICP: In Circuit Programing  

3.Remapping of alternate functions of stm8s chip:

       The stm8s chip has many spare functions, which can only be realized by using the remapping function.

       Remapping is actually configuring a certain bit of a flash address to make a pin have one of the alternate functions or the default function.

       And once the function is changed, it must be rewritten if you want to restore the original function.

       

       For example, the PD4 port of stm8s has TIM2_CH1 function and BEEP function. By default, it is TIM2_CH1 function.

       When we want to use the BEEP function, we must write the option word to remap this pin to the BEEP function.

register:

Multiple alternative functions of stm8s:

 

4. Library function to implement remapping

//For stm8s, the option word address is 0x4803

#define Beep_OptionAdd 0x4803

   void Set_Beep_OptionByte(void)
   {
    uint16_t Beep_Option_status;/*Record the status of activating the optional function Beep/TIM2_CH1*/
    Beep_Option_status=FLASH_ReadOptionByte(Beep_OptionAdd);
    /*The highest bit of Beep_Option_status is 1 to activate Beep, otherwise it is not activated, which is TIM2_CH1*/
     if((Beep_Option_status&0x8000))
     {
      FLASH_ProgramOptionByte(Beep_OptionAdd, (uint8_t)(Beep_Option_status&0x7fff));
    /*Set Beep_OptionAdd 0x4803 to 0, deactivate and activate Beep, and restore the TIM2_CH1 channel*/
     }
  }


Keywords:stm8  OptionByte Reference address:Use of OptionByte of stm8

Previous article:STM8 serial port prints debugging information
Next article:[STM8] Encryption program through STM8 chip unique ID

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号