用下面的代码在仿真器跟踪状态下读写正常,芯片独立运行时不能写入。请高手指点一下。谢谢 //CPU: STM8L101F3P6 主时钟设为2M #define EEPROM_ADDR 0x9800 //--------------------------------------------------------------------- u8 Init_EEPROM(void) { u16 tc=0; do { if(tc<0xffff) tc++; else return 1; FLASH->DUKR=0xae; FLASH->DUKR=0x56; FLASH->CR2=0x00; }while((FLASH->IAPSR & 0x08)==0); return 0; } //----------------------------------------------------------------------- u8 EEPROM_Read(u16 Addr,u8 *RxBuffer,u8 Length) { u8 *EEP; EEP=(u8 *)(EEPROM_ADDR+Addr); if(Init_EEPROM()) return 1; while(Length--){ *RxBuffer++=*EEP++; } FLASH->IAPSR &= (uint8_t)FLASH_MemType_Data;//0xf7 lock return 0; } //----------------------------------------------------------------------- u8 EEPROM_Write(u16 Addr,u8 *RxBuffer,u8 Lenth) { u16 T=0; u8 *EEP; EEP=(u8 *)(EEPROM_ADDR+Addr); if(Init_EEPROM()) return 1; while(Lenth--){ *EEP++=*RxBuffer++; T=0; while((!(FLASH->IAPSR&0x04))&(T<0xFFFF)) T++; if(T==0xFFFF)return 1; } FLASH->IAPSR &= (uint8_t)FLASH_MemType_Data; // 0xf7 lock return 0; } //----------------------------------------------------------------------- |
STMS005K6T6 如何采集内部参考电压。
stm8s003 adc中断和通道切换的问题
adc施密特触发器stm8
stm8l051f3 TSSOP20 封装,待机模式下,2天后,电流突然增加到140UA
STM8S用STVP烧录怎么加密?
如何使用ST官网例程_LIN总线通讯_STM8AF
STM8 LIN
IAR代码编辑太费劲了,想问一下有没有好的方法,试了VScode但是头文件老是报错,调了很久也没调好,想换个方法了。
想问一下各位大佬,IAR下载调试代码时出现 warning: is an illegal data sample expression IAR是什么意思啊?
STM8S标准库TIM1编码器功能不计数,请大师帮我看看
u8 EEPROM_Write(u16 Addr,u8 *RxBuffer,u8 Length)
{
u16 T=0;
uint8_t i=0;
u8 *EEP;
EEP=(u8 *)(EEPROM_ADDR+Addr);
FLASH->CR1 = 0x00;
FLASH->CR2 = 0x00;
while((FLASH->IAPSR&FLASH_FLAG_PUL)==0)
{
FLASH->PUKR = 0x56;
FLASH->PUKR = 0xAE;
}
for(i=0;i<Length;i++)
{
*EEP++=*RxBuffer++;
T=0;
while((FLASH->IAPSR)&FLASH_FLAG_EOP==0){
if(T<0xffff) T++;
else return 1;
};
}
FLASH->IAPSR &= 0xFD;
return 0;
}
//-----------------------------------------------------------------------
用这段代码可以写STM8L101-EEPROM