STC8H1K08-36I-TSSOP20 P14 P15 P16 引脚输出
STC8H1K08-36I-TSSOP20#include "config.h"
#include "STC8G_H_GPIO.h"
#include "STC8G_H_Delay.h"
#define STEP_MS 200
#define DARK_TIME 6
code u8 LED_Table = {
{5,0,0, 5,0,0, 5,0,0, 5,0,0}, // 0:P32
{0,5,0, 0,5,0, 0,5,0, 0,5,0}, // 1:P17
{0,0,5, 0,0,5, 0,0,5, 0,0,5}, // 2:P33
{0,5,0, 0,5,0, 0,5,0, 0,5,0}, // 3:P10
{5,0,0, 5,0,0, 5,0,0, 5,0,0}, // 4:P11
{5,5,5, 5,5,5, 5,5,5, 5,5,5}, // 5:P37
{0,0,5, 5,5,5, 5,5,5, 5,5,5}, // 6:P36
{0,0,0, 0,5,5, 5,5,5, 5,0,0}, // 7:P35
{0,0,0, 0,0,0, 5,5,0, 0,0,0}, // 8:P34
{5,0,0, 0,5,0, 5,0,5, 0,5,0}, // 9:P14开漏,不PWM
{0,5,0, 5,0,0, 0,5,0, 5,0,0}, //10:P15开漏,不PWM
{0,0,5, 0,0,5, 0,0,5, 0,0,5}//11:P16开漏,不PWM
};
u8 timeIndex;
u8 current_state;
u16 cnt;
void GPIO_config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
// P10 P11 P17 → 推挽
GPIO_InitStructure.Pin= GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_7;
GPIO_InitStructure.Mode = GPIO_OUT_PP;
GPIO_Inilize(GPIO_P1, &GPIO_InitStructure);
// P14 P15 P16 → 开漏(硬件限制,必须这样)
GPIO_InitStructure.Pin= GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
GPIO_InitStructure.Mode = GPIO_OUT_OD;
GPIO_Inilize(GPIO_P1, &GPIO_InitStructure);
// P3全部推挽
GPIO_InitStructure.Pin= GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.Mode = GPIO_OUT_PP;
GPIO_Inilize(GPIO_P3, &GPIO_InitStructure);
}
void main(void)
{
EAXSFR();
GPIO_config();
cnt = 0;
while(1)
{
P14 =0;
P15 =0;
P16 =0;
delay_ms(500);
P14 =1;
P15 =1;
P16 =1;
delay_ms(500);
}
}P14P15P16 没有高低电平变化
要输出高低电平,就改推挽或准双向
收到 感谢
页:
[1]