•
Bitwise and logic operations are useful. Not only they are fast, they just deal with the
designated bits only. SPL has support for such operations but it is still better to know them.
Here are some common operations:
#define bit_set(reg, bit_val)
#define bit_clr(reg, bit_val)
#define bit_tgl(reg, bit_val)
#define get_bit(reg, bit_val)
#define get_reg(reg, msk)
Unlocking a Locked STM8 Chip
If you have accidentally locked a STM8 chip by setting the Readout Protection configuration bit and
no longer able to use it, you can unlock it easily.
When you lock a chip, the programmer interface will give you a warning notification. If you retry to
reprogram/erase a locked chip you'll get an error like this:
No matter what you do, you won't be able to use it.
reg |= (1 << bit_val)
reg &= (~(1 << bit_val))
reg ^= (1 << bit_val)
(reg & (1 << bit_val))
(reg & msk)
//For setting a bit of a register
//For clearing a bit of a register
//For toggling a bit of a register
//For extracting the bit state of a register
//For extracting the states of masked bits of a register
Need help?
Do you have a question about the STM8 and is the answer not in the manual?
Questions and answers