好吧!看来我要把所有代码贴出来
#include "stm8s.h"
#include "IAR_OPTIMIZE.h"
#define Number 20
#define SET_PB5 GPIOB->ODR |=0x20
#define CLR_PB5 GPIOB->ODR &=0xDF
u8 R,G,BL;
u16 first_result,second_result,third_result,forth_result,fifth_result;
void Delayms(u16 t) //毫秒延时
{
unsigned int i;
while(t--)
for(i=900;i>0;i--)
{
}
}
void send_2811_24bits_1( u8 dat1, u8 dat2, u8 dat3) //驱动函数
{
u8 a;
IWDG->KR=0xAA; //将看门狗重载寄存器值写入计数器
a=8;
while(a) |