[bsp/es32f0654] switch system clock from 24MHz to 48MHz

This commit is contained in:
wangyq2018 2019-03-01 17:34:21 +08:00
parent 8eb7e02d7b
commit abd83b10df
7 changed files with 48 additions and 40 deletions

View File

@ -9,7 +9,7 @@
### 1.1 开发板介绍
主要内容如下:
ES-PDS-ES32F0654 是东软载波微电子官方推出的一款基于 ARM Cortex-M0 内核的开发板,最高主频为 48Mhz(实际使用24Mhz),可满足基础功能测试及高端功能扩展等开发需求。
ES-PDS-ES32F0654 是东软载波微电子官方推出的一款基于 ARM Cortex-M0 内核的开发板,最高主频为 48MHz,可满足基础功能测试及高端功能扩展等开发需求。
开发板外观如下图所示:
@ -19,30 +19,31 @@ ES-PDS-ES32F0654-V1.0
该开发板常用 **板载资源** 如下:
- MCUES32F0654LT主频 24MHz256KB FLASH32KB RAM54 GPIOs
- 外部 FLASHW25Q128SPI16MB、EEPROM24c02
- MCUES32F0654LT主频 48MHz32KB SRAM256KB FLASH54 GPIOs
- 外部模块SPI FLASH (MX25L648MB)、I2C EEPROM (M24C04512B)
- 常用外设
- LED2个(红色PC8-PC9)
- 可调电阻1个(PB00)
- LED2个(PC8/PC9)
- 按键3个K1(PF00)K2PF01)RESET(MRST)
- 常用接口:串口、GPIO、SPI、I2C
- 常用接口GPIO、UART、SPI、I2C
- 调试接口ESLinkⅡ(EastSoft 官方推出的开发工具有标准版和mini版两种版本均自带 CDC 串口功能) SWD 下载
外设支持:
本 BSP 目前对外设的支持情况如下:
| **板载外设** | **支持情况** | **备注** |
| **板载外设** | **支持情况** | **备注** |
| :---------------- | :----------: | :------------------------------------|
| SPI FLASH | 支持 | |
| **片上外设** | **支持情况** | **备注** |
| **片上外设** | **支持情况** | **备注** |
| :---------------- | :----------: | :------------------------------------|
| GPIO | 支持 | 54 GPIOs |
| UART | 支持 | UART0/1/2/3 |
| SPI | 支持 | SPI0/1 |
| SPI | 支持 | SPI0/1 |
| I2C | 支持 | I2C0/1 |
| **扩展模块** | **支持情况** | **备注** |
| **扩展模块** | **支持情况** | **备注** |
更多详细信息请咨询[上海东软载波微电子技术支持](http://www.essemi.com/)

View File

@ -42,14 +42,11 @@ void NVIC_Configuration(void)
*******************************************************************************/
void SystemClock_Config(void)
{
/* hosc 8MHz, from hosc/2 pll to 48MHz */
cmu_pll1_config(CMU_PLL1_INPUT_HOSC_2, CMU_PLL1_OUTPUT_48M);
/* hosc 12MHz, from hosc/3 pll to 48MHz */
cmu_pll1_config(CMU_PLL1_INPUT_HOSC_3, CMU_PLL1_OUTPUT_48M);
/* MCLK 48MHz*/
cmu_clock_config(CMU_CLOCK_PLL1, 48000000);
/* SYSCLK 24MHz */
cmu_div_config(CMU_SYS, CMU_DIV_2);
}
/*******************************************************************************

View File

@ -60,7 +60,7 @@ static const struct pin_index pins[] =
__ES32F0_PIN(27, B, 1),
__ES32F0_PIN(28, B, 2),
__ES32F0_PIN(29, B, 10),
__ES32F0_PIN_DEFAULT,
__ES32F0_PIN(30, B, 11),
__ES32F0_PIN_DEFAULT,
__ES32F0_PIN_DEFAULT,
__ES32F0_PIN(33, B, 12),

View File

@ -28,6 +28,7 @@ rt_err_t spi_configure(struct rt_spi_device *device,
spi_handle_t *hspi;
hspi = (spi_handle_t *)device->bus->parent.user_data;
/* config spi mode */
if (cfg->mode & RT_SPI_SLAVE)
{
hspi->init.mode = SPI_MODE_SLAVER;
@ -77,13 +78,35 @@ rt_err_t spi_configure(struct rt_spi_device *device,
{
hspi->init.ss_en = ENABLE;
}
/* config spi clock */
if (cfg->max_hz >= cmu_get_pclk1_clock() / 2)
{
hspi->init.baud = SPI_BAUD_2;
/*pclk1 max speed 48MHz, spi master max speed 10MHz*/
if (cmu_get_pclk1_clock() / 2 <= 10000000)
{
hspi->init.baud = SPI_BAUD_2;
}
else if (cmu_get_pclk1_clock() / 4 <= 10000000)
{
hspi->init.baud = SPI_BAUD_4;
}
else
{
hspi->init.baud = SPI_BAUD_8;
}
}
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 4)
{
hspi->init.baud = SPI_BAUD_4;
/*pclk1 max speed 48MHz, spi master max speed 10MHz*/
if (cmu_get_pclk1_clock() / 4 <= 10000000)
{
hspi->init.baud = SPI_BAUD_4;
}
else
{
hspi->init.baud = SPI_BAUD_8;
}
}
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 8)
{
@ -215,7 +238,7 @@ int es32f0_spi_register_bus(SPI_TypeDef *SPIx, const char *name)
}
else if (SPIx == SPI1)
{
_spi1.perh = SPI0;
_spi1.perh = SPI1;
spi_bus = &_spi_bus1;
spi = &_spi1;

View File

@ -42,7 +42,6 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
gpio_init_initstructure.type = GPIO_TYPE_TTL;
#ifdef BSP_USING_UART0
gpio_init_initstructure.func = GPIO_FUNC_3;
gpio_init(GPIOB, GPIO_PIN_10, &gpio_init_initstructure);
@ -51,11 +50,9 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
gpio_init(GPIOB, GPIO_PIN_11, &gpio_init_initstructure);
NVIC_EnableIRQ(UART0_IRQn);
#endif /* uart0 gpio init */
#ifdef BSP_USING_UART1
gpio_init_initstructure.func = GPIO_FUNC_3;
gpio_init(GPIOC, GPIO_PIN_10, &gpio_init_initstructure);
@ -64,11 +61,9 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
gpio_init(GPIOC, GPIO_PIN_11, &gpio_init_initstructure);
NVIC_EnableIRQ(UART1_IRQn);
#endif /* uart1 gpio init */
#ifdef BSP_USING_UART2
gpio_init_initstructure.func = GPIO_FUNC_5;
gpio_init(GPIOC, GPIO_PIN_12, &gpio_init_initstructure);
@ -77,11 +72,9 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
gpio_init(GPIOD, GPIO_PIN_2, &gpio_init_initstructure);
NVIC_EnableIRQ(BS16T1_UART2_IRQn);
#endif /* uart2 gpio init */
#ifdef BSP_USING_UART3
gpio_init_initstructure.func = GPIO_FUNC_4;
gpio_init(GPIOC, GPIO_PIN_4, &gpio_init_initstructure);
@ -90,7 +83,6 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
gpio_init(GPIOC, GPIO_PIN_5, &gpio_init_initstructure);
NVIC_EnableIRQ(BS16T2_UART3_IRQn);
#endif /* uart3 gpio init */
uart->huart.init.mode = UART_MODE_UART;

View File

@ -22,11 +22,11 @@
</DaveTm>
<Target>
<TargetName>rt-thread_es32f065x</TargetName>
<TargetName>rt-thread</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>24000000</CLKADS>
<CLKADS>12000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
@ -73,11 +73,11 @@
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>255</CpuCode>
<CpuCode>0</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
@ -95,7 +95,7 @@
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>0</tRtrace>
<tRtrace>1</tRtrace>
<sRSysVw>1</sRSysVw>
<tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb>
@ -117,18 +117,13 @@
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0ES32F065x -FS00 -FL040000</Name>
<Key>JL2CM3</Key>
<Name>-U12345678 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0ES32F065x.FLM -FS00 -FL040000 -FP0($$Device:ES32F0654LT$Flash\ES32F065x.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0es32f0xx -FL040000 -FS00 -FP0($$Device:ES32F0654LT$Flash\es32f0xx.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U12345678 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0ES32F065x -FS00 -FL040000</Name>
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0ES32F065x -FS00 -FL040000 -FP0($$Device:ES32F0654LT$Flash\ES32F065x.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>

View File

@ -7,7 +7,7 @@
<Targets>
<Target>
<TargetName>rt-thread_es32f065x</TargetName>
<TargetName>rt-thread</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>