-
大小: 6.43MB文件類(lèi)型: .zip金幣: 2下載: 0 次發(fā)布日期: 2023-09-24
- 語(yǔ)言: 其他
- 標(biāo)簽: stm??通信轉(zhuǎn)換??
資源簡(jiǎn)介
通過(guò)dsp通信發(fā)生數(shù)據(jù),將此數(shù)據(jù)實(shí)時(shí)在顯示屏上顯示

代碼片段和文件信息
#include?“stm32f10x.h“
#include?“stm32_gpio.h“
#include?“stm32_tim2.h“
#include?“stm32_can2.h“
unsigned?int?buffer[3][5];
const?unsigned?int?cs[5]?=?{?0xFFEF?0xFFF7?0xFFFB?0xFFFD?0xFFFE?};
const?unsigned?int?tab[19]?=?{?0xFF3F?0xFF06?0xFF5B?0xFF4F?0xFF66?0xFF6D?0xFF7D?0xFF07?0xFF7F?0xFF6F?0xFF770xFF7C?0xFF39?0xFF5E?0xFF79?0xFF71?0xFFBF?0xFF00?0xFF40?};
?//0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 A B C D E F 零點(diǎn), 不顯示 負(fù)號(hào)
char?scan?=?4;
unsigned?int?can_rest?=?0;
long?voltage=0current=0power=0;
/*
*********************************************************************************************************
*
*?函數(shù)名稱:?display
*
*?輸入變量:?buffer地址
*
*?輸出變量:?buffer[pt][0~4]
*
*?功能描述:?LED顯示初始化函數(shù)
*
*********************************************************************************************************
*/
void?stm32_displayer_init(??)
{
unsigned?char?ij;
for(?i?=?0;?i?3??;?i++?)
{
for(?j?=?0;?j?5??;?j++?)
{
buffer[i][j]?=?0xFFFF;
}
}
}
void?displayerr(?unsigned?int?ledErr[5]?unsigned?char?sign?)
{
ledErr[4]?=?tab[14]; //E
ledErr[3]?=?0xFF50; //r
ledErr[2]?=?0xFFD0; //r+“.“
ledErr[1]?=?tab[0]; //0
ledErr[0]?=?tab[sign]; //0為正數(shù)溢出,1為負(fù)數(shù)溢出
}
/*
*********************************************************************************************************
*
*?函數(shù)名稱:?stm32_display
*
*?輸入變量:?long?numunsigned?char?ptunsigned?char?point
*
*?輸出變量:?buffer[pt][0~4]
*
*?功能描述:?LED顯示數(shù)字處理函數(shù)
*
*********************************************************************************************************
*/
void?stm32_display(?long?num?unsigned?pt?unsigned?char?point?)
{
int?temp[7]data_buffer[5];
unsigned?int?i??j?=?1?;
unsigned?char?sign; //num的正負(fù)標(biāo)志位,0為正,1為負(fù)
while((?num?>?99999?)||(?num?-9999?))
{
if(?point?>?0?)
{
num?/=?10;
point--;
}
else?
{
if(?num?>?0?)????????????//正溢出
{
displayerr(?buffer[pt]?0);?????????????????//顯示Err.00
return;
}
else??????????????????????????//負(fù)溢出
{
displayerr(?buffer[pt]?1);?????????????????//顯示Err.01
return;
}
}
} //range?=?num消去小數(shù)部分
if(?num?0?) //判斷num的正負(fù),sign_bit為正負(fù)標(biāo)志為,0為正,1為負(fù)
{
num?=?num?*?-1;
sign?=?1;
}
else?sign?=?0;
for(?i?=?0;?i?5;?i++?)
{
temp[i]?=num?%10;
num?/=?10;
}
if(?temp[point]?==?0?&&?point?!=?0?)?temp[point]?=?16;
for(?j?=?4;?j?>?0?&&?temp[j]?==?0?;?j--?)
{
temp[j]?=?17?+?sign;
temp[j+1]?=?17;
}
data_buffer[0]?=?tab[temp[0]];
data_buffer[1]?=?tab[temp[1]];
data_buffer[2]?=?tab[temp[2]];
data_buffer[3]?=?tab[temp[3]];
data_buffer[4]?=?tab[temp[4]];
if(?point?!=?0?)?data_buffer[point]?|=?0x80;
buffer[pt][0]?=?data_buffer[0];
buffer[pt][1]?=?data_buffer[1];
buffer[pt][2]?=?data_buffer[2];
buffer[pt][3]?=?data_buffer[3];
buffer[pt][4]?=?data_buffer[4];
}
/*
**********
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-02-16?09:49??LedDisplay-PCB41\
?????文件????????3111??2016-08-31?11:25??LedDisplay-PCB41\20160831.txt
?????目錄???????????0??2017-08-30?09:15??LedDisplay-PCB41\APP\
?????文件????????6288??2017-05-06?09:23??LedDisplay-PCB41\APP\main.c
?????文件????????2545??2017-08-30?09:15??LedDisplay-PCB41\APP\stm32_displa
?????文件?????????298??2016-11-05?15:12??LedDisplay-PCB41\APP\stm32_displa
?????目錄???????????0??2017-02-16?09:52??LedDisplay-PCB41\BSP\
?????文件???????????0??2016-10-11?17:54??LedDisplay-PCB41\BSP\main.h
?????文件????????2861??2016-11-04?15:16??LedDisplay-PCB41\BSP\stm32_can2.c
?????文件??????????96??2016-08-09?11:16??LedDisplay-PCB41\BSP\stm32_can2.h
?????文件????????1569??2017-02-16?09:52??LedDisplay-PCB41\BSP\stm32_gpio.c
?????文件??????????98??2016-10-25?11:50??LedDisplay-PCB41\BSP\stm32_gpio.h
?????文件????????1190??2016-10-25?20:37??LedDisplay-PCB41\BSP\stm32_tim2.c
?????文件??????????96??2016-08-09?11:16??LedDisplay-PCB41\BSP\stm32_tim2.h
?????目錄???????????0??2017-08-31?09:00??LedDisplay-PCB41\Project\
?????目錄???????????0??2017-08-31?08:56??LedDisplay-PCB41\Project\DebugConfig\
?????文件????????6956??2015-12-10?17:06??LedDisplay-PCB41\Project\DebugConfig\stm32f107vc_STM32F107VC.dbgconf
?????文件????????6956??2015-12-10?17:06??LedDisplay-PCB41\Project\DebugConfig\stm32f107vc_STM32F107VC_1.0.0.dbgconf
?????文件???????56562??2017-05-06?09:23??LedDisplay-PCB41\Project\Jli
?????文件?????????690??2016-08-09?10:54??LedDisplay-PCB41\Project\Jli
?????文件??????139474??2017-05-06?14:26??LedDisplay-PCB41\Project\LedDisplay.uvguix.alan
?????文件???????70643??2017-08-31?09:00??LedDisplay-PCB41\Project\LedDisplay.uvguix.SDCBUS
?????文件??????138575??2016-08-09?18:09??LedDisplay-PCB41\Project\LedDisplay.uvguix.vpindao
?????文件???????32486??2017-08-31?09:00??LedDisplay-PCB41\Project\LedDisplay.uvoptx
?????文件???????28484??2017-08-31?09:00??LedDisplay-PCB41\Project\LedDisplay.uvprojx
?????目錄???????????0??2017-02-16?09:49??LedDisplay-PCB41\Project\Listings\
?????文件??????110553??2017-05-06?09:23??LedDisplay-PCB41\Project\Listings\LedDisplay.map
?????文件???????60663??2017-02-16?09:52??LedDisplay-PCB41\Project\Listings\startup_stm32f10x_cl.lst
?????目錄???????????0??2017-05-06?09:23??LedDisplay-PCB41\Project\ob
?????文件????????3967??2017-02-16?09:52??LedDisplay-PCB41\Project\ob
?????文件?????????134??2017-02-16?09:52??LedDisplay-PCB41\Project\ob
............此處省略163個(gè)文件信息
評(píng)論
共有 條評(píng)論