感谢测评机会:RA-Eco-RA2E1开发板,主芯片型号为R7FA2E1A7DFL
基于arm的CM23内核, 64kB 的闪存以及 16kB SRAM,4kB 数据闪存,提供与 EEPROM 类似的数据存储功能,48引脚封装,1.6V - 5.5V 的宽工作电压范围,增强型电容式触摸感应单元 (CTSU)。
引脚定义:
Pin Configurations
R7FA2E1A72DFL.pincfg -> g_bsp_pin_cfg
AVCC0 42 ANALOG0_AVCC0 - - - - - - - - IO "Read only" -
AVSS0 43 ANALOG0_AVSS0 - - - - - - - - IO "Read only" -
P000 48 - - - - Disabled - - "ADC0: AN00; CTSU0: TS21; IC
U0: IRQ06" - None - -
P001 47 - - - - Disabled - - "ADC0: AN01; CTSU0: TS22; ICU0: IRQ07" - None - -
P002 46 - - - - Disabled - - "ADC0: AN02; CTSU0: TS23; ICU0: IRQ02" - None - -
P010 45 - - - - Disabled - - "ADC0: AN05; ANALOG0: VREFH0; CTSU0: CFCTS30" - None - -
P011 44 - - - - Disabled - - "ADC0: AN06; ANALOG0: VREFL0; CTSU0: CFCTS31" - None - -
P012 41 - - - - Disabled - - "ADC0: AN07; CTSU0: CFCTS32" - None - -
P013 40 - - - - Disabled - - "ADC0: AN08; CTSU0: CFCTS33" - None - -
P014 39 - - - - Disabled - - "ADC0: AN09" - None - -
P015 38 GPIO - - None "Input mode" - None "ADC0: AN10; CTSU0: CFCTS28; ICU0: IRQ07" - IO - -
P100 36 - - - - Disabled - - "ACMPLP0: CMPIN; ADC0: AN22; AGT0: AGTIO; CTSU0: CFCTS26; GPT_POEG0: GTETRG; GPT8: GTIOCB; ICU0: IRQ02; IIC0: SCL; KINT0: KRM0; SCI0: RXD; SCI0: SCL; SCI1: SCK; SPI0: MISO" - None - -
P101 35 - - - - Disabled - - "ACMPLP0: CMPREF; ADC0: AN21; AGT0: AGTEE; CTSU0: CFCTS16; GPT_POEG1: GTETRG; GPT8: GTIOCA; ICU0: IRQ01; IIC0: SDA; KINT0: KRM1; SCI0: SDA; SCI0: TXD; SCI1: CTS; SPI0: MOSI" - None - -
P102 34 - - - - Disabled - - "ACMPLP1: CMPIN; ADC0: ADTRG; ADC0: AN20; AGT0: AGTO; CTSU0: CFCTS15; GPT_OPS0: GTOWLO; GPT5: GTIOCB; KINT0: KRM2; SCI0: SCK; SCI2: SDA; SCI2: TXD; SPI0: RSPCK" - None - -
P103 33 GPIO - Low - "Output mode (Initial Low)" CMOS - "ACMPLP1: CMPREF; ADC0: AN19; CTSU0: CFCTS14; GPT_OPS0: GTOWUP; GPT5: GTIOCA; KINT0: KRM3; SCI0: CTS; SPI0: SSL0" - IO - -
P104 32 - - - - Disabled - - "CTSU0: CFCTS13; GPT_POEG1: GTETRG; GPT4: GTIOCB; ICU0: IRQ01; KINT0: KRM4; SCI0: RXD; SCI0: SCL; SPI0: SSL1" - None - -
P108 25 DEBUG0_SWDIO - Low - "Peripheral mode" - None "DEBUG0: SWDIO; GPT_OPS0: GTOULO; GPT0: GTIOCB; SCI9: CTS" - IO - -
P109 26 - - - - Disabled - - "CGC0: CLKOUT; CTSU0: CFCTS10; GPT_OPS0: GTOVUP; GPT4: GTIOCA; SCI1: SCK; SCI9: SDA; SCI9: TXD" - None - -
P110 27 - - - - Disabled - - "ACMP(0-1): VCOUT; CTSU0: CFCTS11; GPT_OPS0: GTOVLO; GPT4: GTIOCB; ICU0: IRQ03; SCI2: CTS; SCI9: RXD; SCI9: SCL" - None - -
P111 28 - - - - Disabled - - "AGT0: AGTOA; CTSU0: CFCTS12; GPT6: GTIOCA; ICU0: IRQ04; SCI2: SCK; SCI9: SCK" - None - -
P112 29 - - - - Disabled - - "AGT0: AGTOB; CTSU0: TSCAP; GPT6: GTIOCB; SCI1: SCK; SCI2: SDA; SCI2: TXD" - None - -
P200 21 - - - - Disabled - - "ICU0: NMI" - None - -
P201 20 - - - - Disabled - - "SYSTEM0: MD" - None - -
P206 18 - - - - Disabled - - "GPT_OPS0: GTIU; ICU0: IRQ00; SCI0: RXD; SCI0: SCL" - None - -
P207 17 - - - - Disabled - - - - None - -
P208 16 - - - - Disabled - - "AGT0: AGTOB" - None - -
P212 8 - - - - Disabled - - "AGT1: AGTEE; CGC0: EXTAL; GPT_POEG1: GTETRG; GPT0: GTIOCB; ICU0: IRQ03; SCI1: RXD; SCI1: SCL" - None - -
P213 7 - - - - Disabled - - "CGC0: XTAL; GPT_POEG0: GTETRG; GPT0: GTIOCA; ICU0: IRQ02; SCI1: SDA; SCI1: TXD" - None - -
P214 5 - - - - Disabled - - "CGC0: XCOUT" - None - -
P215 4 - - - - Disabled - - "CGC0: XCIN" - None - -
P300 24 DEBUG0_SWCLK - Low - "Peripheral mode" - None "DEBUG0: SWCLK; GPT_OPS0: GTOUUP; GPT0: GTIOCA" - IO - -
P301 23 - - - - Disabled - - "AGT0: AGTIO; CTSU0: CFCTS09; GPT_OPS0: GTOULO; GPT7: GTIOCB; ICU0: IRQ06; SCI2: RXD; SCI2: SCL; SCI9: CTS" - None - -
P302 22 - - - - Disabled - - "CTSU0: CFCTS08; GPT_OPS0: GTOUUP; GPT7: GTIOCA; ICU0: IRQ05; SCI2: SDA; SCI2: TXD" - None - -
P400 1 - - - - Disabled - - "AGT1: AGTIO; CAC0: CACREF; GPT9: GTIOCA; ICU0: IRQ00; IIC0: SCL; SCI0: SCK; SCI1: SCK" - None - -
P401 2 - - - - Disabled - - "GPT_POEG0: GTETRG; GPT9: GTIOCB; ICU0: IRQ05; IIC0: SDA; SCI0: CTS; SCI1: SDA; SCI1: TXD" - None - -
P407 12 - - - - Disabled - - "ADC0: ADTRG; AGT0: AGTIO; IIC0: SDA; RTC0: RTCOUT; SCI0: CTS" - None - -
P408 11 - - - - Disabled - - "CTSU0: TS04; GPT_OPS0: GTOWLO; ICU0: IRQ07; IIC0: SCL; SCI1: CTS" - None - -
P409 10 - - - - Disabled - - "CTSU0: TS05; GPT_OPS0: GTOWUP; ICU0: IRQ06" - None - -
P500 37 - - - - Disabled - - "GPT_OPS0: GTIU; GPT5: GTIOCA" - None - -
P913 15 - - - - Disabled - - "AGT1: AGTIO; GPT_POEG0: GTETRG" - None - -
P914 14 - - - - Disabled - - "AGT1: AGTOA; GPT_POEG1: GTETRG" - None - -
P915 13 - - - - Disabled - - - - None - -
RES# 19 SYSTEM0_RES - - - - - - - - IO "Read only" -
VCC 9 SYSTEM0_VCC - - - - - - - - IO "Read only" -
VCC 30 SYSTEM0_VCC - - - - - - - - IO "Read only" -
VCL 3 SYSTEM0_VCL - - - - - - - - IO "Read only" -
VSS 6 SYSTEM0_VSS - - - - - - - - IO "Read only" -
VSS 31 SYSTEM0_VSS - - - - - - - - IO "Read only" -
一个明显的特点是和是STM32端口名为PA1、PC13不同,瑞萨的端口名定义为P101、P213,如板载按钮标有P015,板载LED标有P103、P104,触摸按钮标有P109、P110等。
DS18B20是常用的数字温度传感器,其输出的是数字信号,具有体积小,硬件开销低,抗干扰能力强,精度高的特点。电压范围:3.0~5.5V,在寄生电源方式下可由数据线供电。测温范围-55℃~+125℃,在-10~+85℃时精度为±0.5℃,一般采用外部供电方式,并且在数据线上并联一个4.7k的上拉电阻,以增强数据的抗干扰能力。
单线数据传输,我们选择连至P213端口。
为了快速编程,下载瑞萨模板实例:https://github.com/renesas
配置端口:
static void bsp_vbatt_init (ioport_cfg_t const * const p_pin_cfg);
static void r_ioport_pins_config(const ioport_cfg_t * p_cfg);
读取DS18B20温度值:
- short DS18B20_Get_Temperature(void){
- uint8_t temp;
- uint8_t TL,TH;
- short temperature;
- DS18B20_Start();
- DS18B20_Rst();
- DS18B20_Check();
- DS18B20_Write_Byte(0xcc);
- DS18B20_Write_Byte(0xbe);
- TL = DS18B20_Read_Byte();
- TH = DS18B20_Read_Byte();
- if(TH>7){
- TH = ~TH;
- TL = ~TL;
- temp = 0;
- }else
- temp = 1;
- temperature = TH;
- temperature <<= 8;
- temperature += TL;
- temperature = (float)temperature*0.625;
- if(temperature)
- return temperature;
- else
- return -temperature;
- }
- void UART0_Init(void)
- {
- fsp_err_t err = FSP_SUCCESS;
- err = R_SCI_UART_Open (&g_uart0_ctrl, &g_uart0_cfg);
- assert(FSP_SUCCESS == err);
- }
- void Uart0_Callback (uart_callback_args_t * p_args)
- {
- switch (p_args->event)
- {
- case UART_EVENT_RX_CHAR:
- {
- R_SCI_UART_Write(&g_uart0_ctrl, (uint8_t *)&(p_args->data), 1);
- break;
- }
- case UART_EVENT_TX_DATA_EMPTY:
- {
- uart_send_complete_flag = true;
- break;
- }
- default:
- break;
- }
- }