- 2024-12-22
-
回复了主题帖:
【Follow me第二季第3期】扩展任务:一个波形信号发生器
breeze_i 发表于 2024-12-21 20:54
大佬,请问视频中用到的串口工具叫什么名字?
mobaxterm
- 2024-12-19
-
回复了主题帖:
【Follow me第二季第3期】作业任务提交
Jacktang 发表于 2024-12-19 07:29
能否加个固件“下载”按钮?
这个是个好建议
每次烧写都只能debug
- 2024-12-18
-
发表了主题帖:
【Follow me第二季第3期】作业任务提交
首先,真心感谢eeworld && digikey!感谢提供一个很好的学习机会,同时感谢瑞萨做workshop的同学,细致的讲解,反正我看了不下十次。
作业内容:
首先环境搭建出了点小问题,全靠教学视频和大佬们的帮助:
1. 【Follow me第二季第3期】哪位真的按照视频指南完成了E2 STUDIO环境搭建? - DigiKey得捷技术专区 - 电子工程世界-论坛
2. 【Follow me第二季第3期】这个estudio神了,环境设置问题 - DigiKey得捷技术专区 - 电子工程世界-论坛
环境搭建好了后的作业:
3.【Follow me第二季第3期】搭建环境&下载调试示例程序 - DigiKey得捷技术专区 - 电子工程世界-论坛
4. 【Follow me第二季第3期】入门任务:Blink,按键 - DigiKey得捷技术专区 - 电子工程世界-论坛
5. 【Follow me第二季第3期】基础任务:quad-spi flash和octo-spi flash配置及读写速... - DigiKey得捷技术专区 - 电子工程世界-论坛
6. 【Follow me第二季第3期】基础任务:DAC配置生成波形及性能测试 - DigiKey得捷技术专区 - 电子工程世界-论坛
7. 【Follow me第二季第3期】进阶任务:示例程序中新增命令打印信息 - DigiKey得捷技术专区 - 电子工程世界-论坛
8. 【Follow me第二季第3期】扩展任务:一个波形信号发生器 - DigiKey得捷技术专区 - 电子工程世界-论坛
一点感受:
1. RASC工具真心好用,外设配置个人感觉比cubeMX不相上下;E2 studio第一次用,总体上不错,弱弱的建议:能否加个固件“下载”按钮?
2. 第一次接触信号波形,跟着大部队跌跌撞撞的学习然后实现自己的功能,感觉很棒,要是有个示波器就好了;
3. 任务安排的比较合理,循序渐进,譬如现在让我去做blink的功能,我就会选择中断的方式实现LED灯亮灯灭,而不是最初的监视按键电平。
最后,再次感谢eeworld && digikey!!
-
回复了主题帖:
【Follow me第二季第3期】基础任务:DAC配置生成波形及性能测试
根据大佬们的提示从串口发出来数据展示
效果如下:
-
加入了学习《Follow me 第二季第3期成果视频》,观看 成果展示
-
发表了主题帖:
【Follow me第二季第3期】扩展任务:一个波形信号发生器
本帖最后由 Juggernaut 于 2024-12-18 22:52 编辑
一、任务目标
设计一个类似信号发生器功能的例程。可在示例程序上修改。通过命令或按键,设置DAC输出波形,可通过flash存储历史波形等信息。
二、设计思路
直接产生正弦波和三角波,保存在数组中,然后将信号类型存储在flash上,此处选择QSPI flash。
具体交互如下:
三、实现
(一)QSPI R/W
QSPI读写直接配好stack,加上读写函数即可。
readFromFlash/saveToFlash函数:
void readFromFlash(uint8_t *buffer)
{
fsp_err_t err = FSP_SUCCESS;
uint32_t page_read_count = 0;
uint8_t *p_mem_addr = (uint8_t*) QSPI_DEVICE_START_ADDRESS;
spi_flash_protocol_t current_spi_mode;
/* The comms mode of the FLASH device is EXTENDED_SPI by default */
current_spi_mode = SPI_FLASH_PROTOCOL_EXTENDED_SPI;
/* initialise the QSPI, and change mode to that set in FSP */
err = qpi_init ();
if (FSP_SUCCESS == err)
{
/* The comms mode has changed. So if recovering, this new mode required */
current_spi_mode = g_qspi_cfg.spi_protocol;
}
memcpy (&buffer[0], p_mem_addr, 1);
deinit_qspi (current_spi_mode);
}
void saveToFlash(uint8_t *buffer)
{
fsp_err_t err = FSP_SUCCESS;
uint32_t page_write_count = 0;
uint8_t *p_mem_addr = (uint8_t*) QSPI_DEVICE_START_ADDRESS;
spi_flash_protocol_t current_spi_mode;
p_mem_addr = (uint8_t*) QSPI_DEVICE_START_ADDRESS;
err = qpi_init ();
if (FSP_SUCCESS == err)
{
/* The comms mode has changed. So if recovering, this new mode required */
current_spi_mode = g_qspi_cfg.spi_protocol;
}
/* 擦除 QSPI 的指定扇区 */
err = R_QSPI_Erase (&g_qspi_ctrl, p_mem_addr, 4096U);
if (FSP_SUCCESS != err)
{
sprintf (s_print_buffer, "Failed to erase QSPI flash\r\n");
print_to_console ((void*) s_print_buffer);
return;
}
/* 等待擦除完成 */
err = get_flash_status ();
if (FSP_SUCCESS != err)
{
sprintf (s_print_buffer, "Failed to get flash status after erase\r\n");
print_to_console ((void*) s_print_buffer);
return;
}
err = R_QSPI_Write (&g_qspi_ctrl, &buffer[0], p_mem_addr, 1);
if (FSP_SUCCESS != err)
{
sprintf (s_print_buffer, "Failed to write data to QSPI flash\r\n");
print_to_console ((void*) s_print_buffer);
}
else
{
err = get_flash_status ();
if (FSP_SUCCESS != err)
{
sprintf (s_print_buffer, "Failed to get flash status after write\r\n");
print_to_console ((void*) s_print_buffer);
}
}
deinit_qspi (current_spi_mode);
}
(二)正弦波/三角波
正弦波的公式:array = (uint16_t) ((sin ((double) i * 2.0 * 3.1415926 / size) + 1.0) * (4096 / 2.0));
三角波的公式:
size_t half_period = size / 2; // Half period of the triangle wave
for (size_t i = 0; i < size; i++)
{
if (i < half_period)
{
// Rising edge: 0 to 4096
array[i] = (uint16_t) ((double) i / (half_period - 1) * 4096);
}
else
{
// Falling edge: 4096 to 0
array[i] = (uint16_t) ((double) (size - i - 1) / (half_period - 1) * 4096);
}
}
(三)MENU实现
增加一个新的Wave Generator module
wave_generator函数实现如下:
四、测试运行
再来个视频:
[localvideo]595ebe51460d5cb5bb094e5b3a67449d[/localvideo]
-
加入了学习《Follow me第二季第3期 任务汇总》,观看 Follow me第二季第3期 任务汇总
- 2024-12-15
-
加入了学习《【Follow me第二季第3期】EK-RA6M5任务汇总视频》,观看 【Follow me第二季第3期】EK-RA6M5任务汇总视频
-
发表了主题帖:
【Follow me第二季第3期】进阶任务:示例程序中新增命令打印信息
本帖最后由 Juggernaut 于 2024-12-18 22:15 编辑
进阶任务:示例程序中新增命令打印信息
找到s_menu_items[]数组,该数组主要用于路由菜单内容,添加测试内容:
/* Table of menu functions */
static st_menu_fn_tbl_t s_menu_items[] =
{
{"Follow me 3" , kis_follow_menu},
{"Kit Information" , kis_display_menu},
{"Web Server" , eth_emb_display_menu},
{"Network Name Lookup" , eth_www_display_menu},
{"Quad-SPI and Octo-SPI Speed Comparison" , ext_display_menu},
{"Cryptography and USB High speed (MSC)" , enc_display_menu},
{"Next Steps", ns_display_menu },
{"", NULL }
};
加上打印函数kis_follow_menu实现:
/**********************************************************************************************************************
* Function Name: kis_follow_menu
* Description : .
* Return Value : The Kit test demo screen
*********************************************************************************************************************/
test_fn kis_follow_menu(void)
{
int8_t c = -1;
bsp_unique_id_t const * p_uid = R_BSP_UniqueIdGet ();
sprintf (s_print_buffer, "%s%s", gp_clear_screen, gp_cursor_home);
/* ignoring -Wpointer-sign is OK when treating signed char_t array as as unsigned */
print_to_console((void*)s_print_buffer);
sprintf (s_print_buffer, MODULE_NAME, g_selected_menu);
/* ignoring -Wpointer-sign is OK when treating signed char_t array as as unsigned */
print_to_console((void*)s_print_buffer);
/* provide small delay so board_status should be up to date */
vTaskDelay (s_ticks_to_wait);
xEventGroupSetBits (g_update_console_event, STATUS_DISPLAY_MENU_KIS);
while (CONNECTION_ABORT_CRTL != c)
{
c = input_from_console ();
if ((MENU_EXIT_CRTL == c) || (CONNECTION_ABORT_CRTL == c))
{
break;
}
}
xEventGroupClearBits (g_update_console_event, STATUS_DISPLAY_MENU_KIS);
return (0);
}
编译好下载到板子。
1按下去后,因为直接用了KIT INFORMATION的“MODULE_NAME”,故显示“KIT INFORMATION”
也可以修改MODULE_NAME内容,或者在s_print_buffer加入其它要显示的内容。
完成。
-
加入了学习《【Follow me第二季第3期】+ EK_RA6M5作品展示视频》,观看 Follow me第二季第3期 EK_RA6M5作品视频
-
加入了学习《FollowMe第二季第三期-任务提交》,观看 任务提交视频
-
加入了学习《Follow me第二季第3期 视频介绍》,观看 Follow me第二季第3期 任务提交
- 2024-12-12
-
回复了主题帖:
STM32全球线上峰会,STM32N6重磅发布啦!
恭喜您,信息审核通过!
- 2024-11-28
-
发表了主题帖:
【Follow me第二季第3期】基础任务:DAC配置生成波形及性能测试
在e2 studio中建立工程。
在RASC中配置好DAC0的针脚P014。
在RASC的stack中新增DAC。
DAC波形产生需要使用定时器,新建个定时器,配置好定时器的属性,以及回调函数。
实现g_timer0_callback函数。
void g_timer0_callback(timer_callback_args_t * p_args)
{
uint16_t dacvalue=0;
static double w=0.0;
w+=M_PI/90;
if(w>=2*M_PI)
{
w=0.0;
}
dacvalue=(sin(w) + 1) / 2 * 4096;
R_DAC_Write(&g_dac0_ctrl, dacvalue);
}
点击生成配置,然后编译。
Extracting support files...
23:37:50 **** 项目DAC配置Debug的增量构建 ****
make -r -j8 all
arm-none-eabi-size --format=berkeley "DAC.elf"
text data bss dec hex filename
3660 8 1560 5228 146c DAC.elf
23:37:51 Build Finished. 0 errors, 0 warnings. (took 176ms)
因为没示波器,不能监视针脚P014的波形,待我想个办法。
##待续
补充内容 (2024-12-18 22:56):
根据大佬们的提示从串口发出来数据展示
-
发表了主题帖:
【Follow me第二季第3期】基础任务:quad-spi flash和octo-spi flash配置及读写速...
在e2 studio中把工程建立起来,选择好芯片型号。
逐步生成工程文件:
quad-spi flash配置
很方便的在e2 studio中配置好QSPI FLASH,CLK也配置好
octo-spi flash配置
配置完成后点击生成配置和驱动,ospi_performance_test的源码如下,分别提供OSPI flash的读写测试结果:
/**********************************************************************************************************************
* Function Name: ospi_performance_test
* Description : .
* Arguments : data_size
* : ospi_performance_write_result
* : ospi_performance_read_result
* Return Value : .
*********************************************************************************************************************/
void ospi_performance_test(uint32_t data_size,
uint32_t *ospi_performance_write_result,
uint32_t *ospi_performance_read_result)
{
fsp_err_t err;
uint32_t i = 1;
if (R_CGC_Open (g_cgc.p_ctrl, g_cgc.p_cfg) != FSP_SUCCESS)
{
__asm("bkpt");
}
while (i)
{
err = R_OSPI_Open(g_ospi.p_ctrl, g_ospi.p_cfg);
if (FSP_SUCCESS != err)
{
__asm("bkpt");
}
#if HIGH_SPEED_MODE
configure_dopi_ospi();
ospi_test_wait_until_wip();
#endif
*ospi_performance_write_result = write_dopi_ospi(data_size);
ospi_test_wait_until_wip();
*ospi_performance_read_result = read_dopi_ospi(data_size);
ospi_test_wait_until_wip();
erase_dopi_ospi();
ospi_test_wait_until_wip();
#if HIGH_SPEED_MODE
configure_spi_ospi();
ospi_test_wait_until_wip();
#endif
err = R_OSPI_Close(g_ospi.p_ctrl);
if (FSP_SUCCESS != err)
{
__asm("bkpt");
}
i--;
}
}
QSPI flash的写测试实现如下:
* Function Name: qspi_write_test
* Description : .
* Argument : block_size
* Return Value : .
*********************************************************************************************************************/
static uint32_t qspi_write_test(uint32_t block_size)
{
fsp_err_t fsp_err;
uint32_t qspi_write_result = 0;
timer_status_t status = {};
fsp_err_t err = FSP_SUCCESS;
spi_flash_protocol_t current_spi_mode;
/* Convert from kB */
block_size *= 1024;
/* The comms mode is EXTENDED_SPI by default */
current_spi_mode = SPI_FLASH_PROTOCOL_EXTENDED_SPI;
/* initialise the QSPI, and change mode to that set in FSP */
err = qpi_init();
if (FSP_SUCCESS == err)
{
/* The comms mode has changed. So if recovering, this new mode required */
current_spi_mode = g_qspi_cfg.spi_protocol;
}
uint32_t page_write_count = 0;
uint8_t * p_mem_addr;
/* Cast to req type */
p_mem_addr = (uint8_t *)QSPI_DEVICE_START_ADDRESS;
while (((page_write_count * SECTOR_SIZE) < block_size)
&& ( FSP_SUCCESS == err ) )
{
/* Erase Flash for one sector */
err = R_QSPI_Erase(&g_qspi_ctrl, p_mem_addr, SECTOR_SIZE);
if (FSP_SUCCESS != err)
{
sprintf(s_print_buffer, "R_QSPI_Erase Failed\r\n");
}
else
{
err = get_flash_status();
if (FSP_SUCCESS != err)
{
sprintf(s_print_buffer, "Failed to get status for QSPI operation\r\n");
}
/* Verify the erased block data */
uint32_t count;
for (count = 0; count < SECTOR_SIZE; count++ )
{
if (DEFAULT_MEM_VAL != p_mem_addr[count])
{
/* Verification failed, perhaps the ERASE failed */
err = FSP_ERR_NOT_ERASED;
}
}
}
p_mem_addr += SECTOR_SIZE;
page_write_count++;
}
/* Start the test timer */
fsp_err = R_GPT_Start(g_memory_performance.p_ctrl);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
/* Cast to req type */
p_mem_addr = (uint8_t *)QSPI_DEVICE_START_ADDRESS;
page_write_count = 0;
while (((page_write_count * PAGE_WRITE_SIZE) < block_size)
&& (FSP_SUCCESS == err))
{
if (FSP_SUCCESS == err)
{
/* Write data to QSPI Flash */
/* Each block begins one character shifted along the source text. To avoid regular striping in memory */
err = R_QSPI_Write(&g_qspi_ctrl, &(sp_source[page_write_count]), p_mem_addr, PAGE_WRITE_SIZE);
if (FSP_SUCCESS != err)
{
sprintf(s_print_buffer, "R_QSPI_Write Failed\r\n");
}
else
{
err = get_flash_status();
if (FSP_SUCCESS != err)
{
sprintf(s_print_buffer, "Failed to get status for QSPI operation\r\n");
}
}
}
p_mem_addr += PAGE_WRITE_SIZE;
page_write_count++;
}
/* close QSPI module */
deinit_qspi(current_spi_mode);
fsp_err = R_GPT_Stop(g_memory_performance.p_ctrl);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
fsp_err = R_GPT_StatusGet(g_memory_performance.p_ctrl, &status);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
fsp_err = R_GPT_Reset(g_memory_performance.p_ctrl);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
qspi_write_result = status.counter;
return (qspi_write_result);
}
QSPI flash的读测试代码如下:
/**********************************************************************************************************************
* Function Name: qspi_read_test
* Description : .
* Argument : block_size
* Return Value : .
*********************************************************************************************************************/
static uint32_t qspi_read_test(uint32_t block_size)
{
fsp_err_t fsp_err;
fsp_err_t err = FSP_SUCCESS;
uint32_t qspi_read_result = 0;
timer_status_t status = {};
spi_flash_protocol_t current_spi_mode;
uint8_t * p_dma_read_buffer;
uint32_t page_read_count;
uint8_t * p_mem_addr;
/* Convert from kB */
block_size *= 1024;
p_dma_read_buffer = pvPortMalloc(block_size);
if (NULL == p_dma_read_buffer)
{
HeapStats_t pxHeapStats;
vPortGetHeapStats(&pxHeapStats);
sprintf(s_print_buffer, "\r\nQSPI malloc operation Failed - Max free mem: %dbytes\r\n",
pxHeapStats.xSizeOfLargestFreeBlockInBytes);
/* Verification failed, perhaps the ERASE failed */
err = FSP_ERR_NOT_ERASED;
}
/* The comms mode of the FLASH device is EXTENDED_SPI by default */
current_spi_mode = SPI_FLASH_PROTOCOL_EXTENDED_SPI;
/* initialise the QSPI, and change mode to that set in FSP */
err = qpi_init();
if (FSP_SUCCESS == err)
{
/* The comms mode has changed. So if recovering, this new mode required */
current_spi_mode = g_qspi_cfg.spi_protocol;
}
/* Start the test timer */
fsp_err = R_GPT_Start(g_memory_performance.p_ctrl);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
page_read_count = 0;
/* cast to req type */
p_mem_addr = (uint8_t *)QSPI_DEVICE_START_ADDRESS;
while (((page_read_count * PAGE_WRITE_SIZE) < block_size)
&& (FSP_SUCCESS == err))
{
/* Verify the written data */
/* Each block begins one character shifted along the source text. To avoid regular striping in memory */
if ((fsp_err_t) (memcmp (p_mem_addr, &(sp_source[page_read_count]), PAGE_WRITE_SIZE)) != FSP_SUCCESS)
{
err = FSP_ERR_NOT_ERASED;
sprintf(s_print_buffer, "\r\nQSPI operation Failed -> Data read does not match with written data\r\n");
}
p_mem_addr += PAGE_WRITE_SIZE;
page_read_count++;
}
fsp_err = R_GPT_Stop(g_memory_performance.p_ctrl);
/* close QSPI module */
deinit_qspi(current_spi_mode);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
fsp_err = R_GPT_StatusGet(g_memory_performance.p_ctrl, &status);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
fsp_err = R_GPT_Reset(g_memory_performance.p_ctrl);
/* Handle error */
if (FSP_SUCCESS != fsp_err)
{
/* Fatal error */
SYSTEM_ERROR
}
qspi_read_result = status.counter;
vPortFree(p_dma_read_buffer);
return (qspi_read_result);
}
测试效果如下
##完成!
-
发表了主题帖:
【Follow me第二季第3期】入门任务:Blink,按键
本帖最后由 Juggernaut 于 2024-11-28 08:44 编辑
先把工程建立起来,FSP很方便,选择好芯片型号:
Blink配置
根据EK-RA6M5的PCB,P006,P007,P008分别对应LED1,LED2,LED3,逐一配置好,此处为输出模式,本案例LED1/LED2用于blink,LED3用于响应案件事件。
代码为
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_06, BSP_IO_LEVEL_HIGH); //LED1亮
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_07, BSP_IO_LEVEL_HIGH); //LED2亮
R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS); //延时500ms
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_06, BSP_IO_LEVEL_LOW); //LED1灭亮
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_07, BSP_IO_LEVEL_LOW); //LED2灭亮
R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS); //延时500ms
按键功能
按键选择按钮2,对应的pin为P005:
同样配置好,此处为输入模式:
代码为:
R_IOPORT_PinRead(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_05, &key_state);
if(key_state==BSP_IO_LEVEL_LOW){
//软件消抖
R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
//点亮LED3
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_08, BSP_IO_LEVEL_HIGH); //LED3亮
//等待按键松开
while(key_state==BSP_IO_LEVEL_LOW)
{
R_IOPORT_PinRead(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_05, &key_state);
}
//熄灭LED3
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_08, BSP_IO_LEVEL_LOW); //LED3灭
}
运行测试
配置好后,点击生成代码按钮,FSP很方便的生成配置和代码。
编辑好:
Extracting support files...
08:40:33 **** 项目blink配置Release的增量构建 ****
make -r -j8 all
arm-none-eabi-size --format=berkeley "blink.elf"
text data bss dec hex filename
4284 8 2580 6872 1ad8 blink.elf
08:40:34 Build Finished. 0 errors, 0 warnings. (took 157ms)
下载至EK-RA65板子:
可以看出LED1 LED2都在blink了,LED3根据按键2的动作响应。
[localvideo]334a9aaf90a69a9b394459e091bd4b23[/localvideo]
至此,BLINK和按键任务完成!
- 2024-11-27
-
发表了主题帖:
【Follow me第二季第3期】搭建环境&下载调试示例程序
终于搞定了e2 studio+fsp。
我用的环境是:setup_fsp_v5_6_0_e2s_v2024-1
FSP的案例是:ra-fsp-examples-master
e2 studio版本信息如下:
Renesas e² studio
Version: 2024-10 (24.10.0)
Build Id: R20241003-1714
Parts Copyright (C) 2010-2024 Renesas Electronics Corp.
All rights reserved.
e² studio IDE is an extension of software developed for
eclipse.org.
e² studio IDE is based on Eclipse Platform 4.32 (2024-06)
and CDT version 11.6.1.
尤其注意的是编译器要设置好,否则会出错:
e2 studio安装好后,按照视频教程导入案例工程,
直接编译:
连上EK-RA6M5开发板,烧入固件。
##完成
- 2024-11-24
-
回复了主题帖:
说一个一直坚持的习惯
有啥效果吗
- 2024-11-21
-
回复了主题帖:
【Follow me第二季第3期】哪位真的按照视频指南完成了E2 STUDIO环境搭建?
beyond_笑谈 发表于 2024-11-21 16:02
开发环境搭建好之后,可以跟着视频学习,我这个帖子的内容是跟着视频学的
【Follow me第二季第3期】程 ...
明天试试
今天不熬夜了
-
回复了主题帖:
【Follow me第二季第3期】哪位真的按照视频指南完成了E2 STUDIO环境搭建?
看看发帖时间,大半夜的
造孽啊