在线时间0 小时
UID355950
ST金币0
蝴蝶豆0
注册时间2012-4-29
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
最近在学习STM32,在论坛下了很多资料,“老杀鸡不养鸡”实在有点说不过去,最近写了几个关于DMX方面的]程序,调试效果不错!现在贴出来供大家分享!
#include 10)
DMXCount = 0;
ChanCount = 0;
ChanAddr = 0;
}
else if(RB8==1)
{
if(ChanCount < 513)
ChanCount ++;
if((ChanCount == 1) && (SBUF == 'A') && (AddrFlagCount < 10)) //修改地址
AddrFlagCount ++;
if((ChanCount == 1) && (SBUF != 'A')) //不修改地址
AddrFlagCount = 0;
if(AddrFlagCount > 5)
AddrFlag = 1;
else
AddrFlag = 0;
if((AddrFlag == 1) && (ChanCount == 2))
AddrH = SBUF;
if((AddrFlag == 1) && (ChanCount == 3))
AddrL = SBUF;
if(AddrFlag == 0)
{
if(ChanCount == 1)
{
Channel[0] = SBUF;
ChanAddr ++;
}
if((ChanCount > Addr) && (ChanCount 50)
{
ScanCount = 0;
if(DMXCount < 1030)
DMXCount ++;
//ADC
if(ADCSelect == 0)
{
if((ADC_CONTR & 0x10) == 0)
{
ADC_CONTR &= 0xF8;
ADC_CONTR |= 0x08;
}
else
{
ADCData1 = ADC_DATA;
ADC_CONTR &= 0xEF;
ADCSelect = !ADCSelect;
}
}
else
{
if((ADC_CONTR & 0x10) == 0)
{
ADC_CONTR &= 0xF8;
ADC_CONTR |= 0x09;
}
else
{
ADCData2 = ADC_DATA;
ADC_CONTR &= 0xEF;
ADCSelect = !ADCSelect;
}
}
//温控处理.
PowerDownC ++;
if(PowerDownC > 2800)
{
PowerDownC = 0;
if(ADCData1 > 205)
{
if(FallCnt > 0)
FallCnt --;
}
else
{
if(FallCnt < 128)
FallCnt ++;
}
}
}
// if(DMXCount < 65530)
// DMXCount ++;
if(DMXCount > 1000)
{
CCAP0H = 255 * FallCnt / 128; //调光.
CCAP1H = 255 * FallCnt / 128; //调光.
CCAP2H = 255 * FallCnt / 128; //调光.
}
else
{
CCAP0H = Channel[1] * FallCnt / 128; //调光.
CCAP1H = Channel[2] * FallCnt / 128; //调光.
CCAP2H = Channel[3] * FallCnt / 128; //调光.
}
}
}
|
|