续前【RA-Eco-RA2E1-48PIN-V1.0开发板试用】3、第一个程序增加printf输出
运行rasc.exe打开上次位置项目,
在Stacks项中 点击Stacks->New Stack->Analog-> ADC(r_adc)。
选择0,5通道。
选择p0,p10引脚。
增加代码
volatile bool scan_complete_flag = false;
voidadc_callback (adc_callback_args_t * p_args)
{
FSP_PARAMETER_NOT_USED(p_args);
scan_complete_flag = true;
}
在/*
TODO:
add your own code here */
下增加:
fsp_err_t err = FSP_SUCCESS;
err = R_ADC_Open(&g_adc0_ctrl,
&g_adc0_cfg);
assert(FSP_SUCCESS == err);
err = R_ADC_ScanCfg(&g_adc0_ctrl,
&g_adc0_channel_cfg);
assert(FSP_SUCCESS == err);
double a0,a5;
uint16_t adc_data1=0;
uint16_t adc_data2=0;
在while(1)中增加
/*
Enable scan triggering from ELC events. */
(void) R_ADC_ScanStart(&g_adc0_ctrl);
scan_complete_flag = false;
while (!scan_complete_flag)
{
/*
Wait for callback to set flag. */
}
err =R_ADC_Read(&g_adc0_ctrl, ADC_CHANNEL_0, &adc_data1);
assert(FSP_SUCCESS == err);
a0=(adc_data1/4095.0)*3.3;
err =R_ADC_Read(&g_adc0_ctrl, ADC_CHANNEL_5, &adc_data1);
assert(FSP_SUCCESS == err);
a5=(adc_data1/4095.0)*3.3;
R_BSP_SoftwareDelay (20, BSP_DELAY_UNITS_MILLISECONDS);
编译:
linking...
Program Size: Code=6604 RO-data=680 RW-data=8 ZI-data=10336
FromELF: creating hex file...
After Build - User command #1: cmd /c "start "Renesas" /w cmd /c ""E:\lst\ra0e1-20240827154516\123\new1\FSP_Project\rasc_launcher.bat" "E:\lst\ra0e1-20240827154516\123\new1\FSP_Project\rasc_version.txt" -nosplash --launcher.suppressErrors --gensmartbundle --compiler ARMv6 --devicefamily ra "E:\lst\ra0e1-20240827154516\123\new1\FSP_Project\configuration.xml"
"E:\lst\ra0e1-20240827154516\123\new1\FSP_Project\Objects\FSP_Project.axf"
2> "%TEMP%\rasc_stderr.out"""
".\Objects\FSP_Project.axf" - 0
Error(s), 47 Warning(s).
Build Time Elapsed: 00:00:33
下生成FSP_Project.hex文件。
Renesas Flash Programmer下载
重新设boot引脚
reset com 口printf输出:
Hello,
i am m
culover666
Test int: i = 100Test float: i =
1.234000Test hex: i = 0x64[app info
led off][app info led on]a0:
3.300000
a5: 3.101758
Hello, i am mculover666
Test
int: i = 100Test float: i = 1.234000Test hex: i = 0x64[app info led off][app
in
fo led on]a0: 3.300000
a5: 3.160586
Hello, i am
mculover666
Test int: i = 100Tes
t float: i = 1.234000Test hex: i = 0x64[app info led off][app info led
on]a0:
3.300000
a5:
3.098535
Hello, i am mculover666
Test int: i = 100Test float: i = 1.
234000Test
hex: i = 0x64[app info led off][app info led on]a0: 3.300000
a5: 3.
164615
Hello, i am mculover666
Test int: i =
100Test float: i = 1.234000Test hex:
i = 0x64[app info led off][app info led on]a0: 3.300000
a5: 3.109817
Hello, i am mculover666
Test int: i = 100Test float: i = 1.234000Test hex: i = 0x64[app info led
off][app info led on]a0: 3.300000
a5: 3.138828
Hello, i am mculover666
Test int: i = 100Test float: i = 1.234000Test hex: i = 0x64[app info led
off][app info led on]a0: 3.300000
a5: 3.153333
Hello, i am mculover666
Test int: i = 100Test float: i = 1.234000Test
hex: i = 0x64[app info led off][app info led on]a0: 3.300000
a5: 3.106593
Hello, i
am mculover666
Test int: i = 100Test float:
i = 1.234000Test hex: i = 0x64[app info led off][app info led on]a0: 3.300000
a5: 3.171062
com
达到预期状态。