本帖最后由 34af9uc 于 2022-9-6 23:11 编辑
应广PFC886取表怎么写见下方,撸码(必须贵单片机16位宽总线才支持查表)
/*******************PFC886/MF520*******************/
/*******************6PWM***************************/
/*******************20220901***********************/
/******************IDE:0.95************************/
/**************************************************/
// ______ ______
// PWM2L-|1 PA2 \_/PA1 16|-PWM2H
// PWM1L-|2 PA3 PA0 15|-PWM1H
// PWM0L-|3 PA4 PA7 14|-pwm0H
// |4 PA5 PA6 13|
// |5 GND VCC 12|
// |6 PB0 PB7 11|
// k1-|7 PB1 PB6 10|
// k2-|8_PB2____PB5__9|-led
/**************************************************/
/**************************************************/
#include "extern.h"
CONST WORD biao [] = { 0x0001,0xffff,0x5aa5,0xffff}; //最多255个
led_0 bit pb.5;
led_1 bit pb.6;
led_2 bit pb.7;
led_3 bit pa.6;
led_4 bit pa.7;
led_5 bit pa.0;
led_6 bit pa.1;
led_7 bit pa.3;
led_l bit pa.5;
led_h bit pa.4;
k1 bit pb.1;
k2 bit pb.2
byte xian;
void xianshi(); //显示
/**************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
pmode Program_Mode; // if has more FPPAs than 2
fppen = 0xFF;
nop;nop;nop;
/**************************************************/
$ led_0 out,low;
$ led_1 out,low;
$ led_2 out,low;
$ led_3 out,low;
$ led_4 out,low;
$ led_5 out,low;
$ led_6 out,low;
$ led_7 out,low;
$ led_l out,low;
$ led_h out,low;
$ k1 in,ph; //输入上拉
$ k2 in,ph;
//$ led out,low;
/**************************************************/
//CONST WORD biao [] = { 0x1234, 0x5678, 0xABCD };
BYTE shift = 2;
WORD All_Data = biao [shift];
/**************************************************/
//$
while (1)
{
xian=All_Data $1;
xianshi(); //显示
led_h=1;
.delay 2000000;
led_h=0;
.delay 200000;
xian=All_Data $0;
xianshi(); //显示
led_l=1;
.delay 2000000;
led_l=0;
.delay 200000;
}
}
/**************************************************/
void FPPA1 (void)
{
while(1)
{
//if(k1==0){led1=1;}// else{led1=0;}
//if(k2==0){led1=0;}// else{led1=0;}
}
}
/**************************************************/
void FPPA2 (void)
{
goto $;
}
/**************************************************/
void FPPA3 (void)
{
goto $;
}
/**************************************************/
void FPPA4 (void)
{
goto $;
}
/**************************************************/
void FPPA5 (void)
{
goto $;
}
/**************************************************/
void FPPA6 (void)
{
goto $;
}
/**************************************************/
void FPPA7 (void)
{
goto $;
}
/**************************************************/
/*
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
*/
/**************************************************/
void xianshi() //显示
{
if(xian.0){led_0=1;} else{led_0=0;}
if(xian.1){led_1=1;} else{led_1=0;}
if(xian.2){led_2=1;} else{led_2=0;}
if(xian.3){led_3=1;} else{led_3=0;}
if(xian.4){led_4=1;} else{led_4=0;}
if(xian.5){led_5=1;} else{led_5=0;}
if(xian.6){led_6=1;} else{led_6=0;}
if(xian.7){led_7=1;} else{led_7=0;}
}
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/
|