資源簡介
IAR工程例子,STM8L單片機,包含LORA初始化,CAD發送,隨機延時切實可行的例程,根據擴頻因子(主要是空中傳輸時間)來調整隨機延時的基礎時間。

代碼片段和文件信息
#include?“adc.h“
#include?“timer1.h“
#include?“ram.h“
#include?“lcd_dms689.h“
//=========================================================================================================================================================================================
UNION_uHEX2?ADC1_Dat;
float?ADC1_Sum=0;
unsigned?char?ADC1_i=0;
//=========================================================================================================================================================================================
void?ADC_User_Config(void)
{
//PA_DDR_bit.DDR6 =0; //設置PA->6?為輸入
///PA_CR1_bit.C16 =0; //設置為懸空輸入?
//PA_CR2_bit.C26 =0; //設置中斷禁止?
ADC1_CR1_bit.RES =0; //設置為12位轉換模式
ADC1_CR1_bit.CONT =0; //設置為單次轉換模式
ADC1_CR2_bit.PRESC =1; //ADC時鐘進行2分頻
ADC1_CR2_bit.SMTP1 =7; //
ADC1_CR3_bit.SMTP2 =7; //384?ADC時鐘進行采樣一次
ADC1_SQR4_bit.CHSEL_S0 =1; //SELECT?AIN0
ADC1_CR1_bit.ADON =1; //使能ADC1
}
//=========================================================================================================================================================================================
void?ADC_Data_Read(void)
{
float?Temp;
if(ADC1_SR_bit.EOC==1)
{
ADC1_SR_bit.EOC =0;
ADC1_Dat.uhex[0] =ADC1_DRH;
ADC1_Dat.uhex[1] =ADC1_DRL;
Temp=5.7*3.3*ADC1_Dat.uHex2/4096.0+0.05; //得到的數值單位為v
if(ADC1_First_Flag==1)
{
Angle[3] =0.9*Angle[3]+0.1*Temp;
Temp =5.0*Angle[3]-14.5;
if(Angle[3]<2.9)
SYS_ON_Step =0;
if(Temp<1.0)
{
Temp =1.0;
Power_Flash_Flag =1;
}
else
Power_Flash_Flag =0;
if(Temp>5.0)
Temp =5.0;
Batty_Count =(unsigned?char)(Temp);
//Angle[0] =Angle[3]/2.0; //測試顯示用
PWM_Count.uHex2 =(unsigned?short)(2032.6644526*Angle[3]*Angle[3]-19440.868245*Angle[3]+47799.897562); //測試顯示用
if(PWM_Count.uHex2>7998) PWM_Count.uHex2 =7998;
if(PWM_Count.uHex2<800) PWM_Count.uHex2 =800;
}
else
{
ADC1_Dly_Count++;
if(ADC1_Dly_Count>6)
{
ADC1_First_Flag =1;
Angle[3] =Temp;
}
}
}
}
//=========================================================================================================================================================================================
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????110880??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Exe\templproj.out
?????文件??????15650??2018-12-16?17:24??USB轉LORA無線模塊01\Debug\Obj\adc.o
?????文件??????10359??2018-12-16?17:24??USB轉LORA無線模塊01\Debug\Obj\adc.pbi.cout
?????文件??????23111??2018-12-16?17:24??USB轉LORA無線模塊01\Debug\Obj\ads1226.o
?????文件??????10363??2018-12-16?17:24??USB轉LORA無線模塊01\Debug\Obj\ads1226.pbi.cout
?????文件???????5481??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\delay.o
?????文件????????759??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\delay.pbi
?????文件??????10361??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\delay.pbi.cout
?????文件???????8184??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\eerom.o
?????文件?????527869??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\eerom.pbi
?????文件??????10361??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\eerom.pbi.cout
?????文件??????10660??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\filter.o
?????文件??????10362??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\filter.pbi.cout
?????文件??????13637??2018-12-16?17:21??USB轉LORA無線模塊01\Debug\Obj\ht1621b.o
?????文件??????10363??2018-12-16?17:21??USB轉LORA無線模塊01\Debug\Obj\ht1621b.pbi.cout
?????文件??????41731??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\i2c_io.o
?????文件??????10362??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\i2c_io.pbi.cout
?????文件??????11112??2018-12-23?15:31??USB轉LORA無線模塊01\Debug\Obj\io_exti.o
?????文件??????10363??2018-12-23?15:31??USB轉LORA無線模塊01\Debug\Obj\io_exti.pbi.cout
?????文件??????36713??2018-12-16?17:19??USB轉LORA無線模塊01\Debug\Obj\key.o
?????文件??????10359??2018-12-16?17:20??USB轉LORA無線模塊01\Debug\Obj\key.pbi.cout
?????文件??????57085??2018-12-16?17:21??USB轉LORA無線模塊01\Debug\Obj\lcd_dms689.o
?????文件??????10366??2018-12-16?17:21??USB轉LORA無線模塊01\Debug\Obj\lcd_dms689.pbi.cout
?????文件???????5256??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\main.o
?????文件?????550119??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\main.pbi
?????文件??????10360??2019-02-11?21:49??USB轉LORA無線模塊01\Debug\Obj\main.pbi.cout
?????文件??????11798??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\mpu6050.o
?????文件?????643326??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\mpu6050.pbi
?????文件??????10363??2018-12-16?17:23??USB轉LORA無線模塊01\Debug\Obj\mpu6050.pbi.cout
?????文件??????14787??2018-12-16?17:21??USB轉LORA無線模塊01\Debug\Obj\poly_fit.o
............此處省略98個文件信息
- 上一篇:QT5下實現基于TCP發送和接接收文件
- 下一篇:2016年考研核心考點——數據結構
評論
共有 條評論