埃斯提爱慕
发布时间:2024-5-24 18:46
|
``` # U083Necule TRNG ## 通过CubeMX创建工程






## 生成代码,直接编译下载运行 
## 看不懂,直接OK吧。 
## 运行OK,串口调试会收到Welcome to STM32 world ! 这是Demo里自带的 
## 只要调用这个函数 
## 在原按键程序里,添加两行代码,即可实现 if (BspButtonState == BUTTON_PRESSED) { /* Update button state */ BspButtonState = BUTTON_RELEASED; /* -- Sample board code to toggle leds ---- */ BSP_LED_Toggle(LED_GREEN); /* ..... Perform your action ..... */ HAL_RNG_GenerateRandomNumber(&hrng, &Trng); printf("The random number is: %d !\n\r", Trng); } 
## 至此,一个简单的随机数生成并打印功能实现。 ## 接下来修改为中断方式,回到cubeMX,使能中断 
## 修改程序 if (BspButtonState == BUTTON_PRESSED) { /* Update button state */ BspButtonState = BUTTON_RELEASED; /* -- Sample board code to toggle leds ---- */ BSP_LED_Toggle(LED_GREEN); /* ..... Perform your action ..... */ HAL_RNG_GenerateRandomNumber_IT(&hrng); } ## 添加回调函数 void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef *hrng, uint32_t random32bit) { printf("The random number is: %d !\n\r", random32bit); } ## 编译运行 
## 中断方式也实现。 ``` |
实战经验 | STM32CubeIDE实用技巧之如何指定变量、函数、文件到指定内存
【STM32U3 评测】步进电机驱动
【STM32U3 评测】MNIST 数字识别
【STM32U3 评测】介绍、环境搭建、工程测试
STM32Cube嵌入式软件更新
一步到位!STM32CubeIDE 搭建 ClassB 功能安全工程
扩展器件适配、优化开发流程——STM32CubeIDE 2.1.0新版本发布
留言赢礼 | 全新升级的STM32CubeIDE for Visual Studio Code
直播回顾 | STM32CubeIDE for VS Code开发新体验
经验分享 | LAT1485 STM32CubeIDE实用技巧之条件断点的妙用
微信公众号
手机版