当前位置: 首页 > news >正文

济南大型网站设计公司seo优化网站教程百度

济南大型网站设计公司,seo优化网站教程百度,网站运营包括哪些,本地php网站搭建环境STM32存储左右互搏 I2C总线读写FRAM MB85RC16 在较低容量存储领域,除了EEPROM的使用,还有铁电存储器FRAM的使用,相对于EEPROM, 同样是非易失性存储单元,FRAM支持更高的访问速度, 其主要优点为没有EEPROM持续写操作跨页…

STM32存储左右互搏 I2C总线读写FRAM MB85RC16

在较低容量存储领域,除了EEPROM的使用,还有铁电存储器FRAM的使用,相对于EEPROM, 同样是非易失性存储单元,FRAM支持更高的访问速度, 其主要优点为没有EEPROM持续写操作跨页地址需要变换的要求,没有写之后的延时等待要求。MB85RC16是2K Byte(16K bit)的FRAM,能够按字节进行写入且没有写入等待时间。其管脚功能兼容相应容量的EEPOM:
在这里插入图片描述
I2C总线访问的FRAM更大容量的型号还有MB85RC128及MB85RC256等。
这里介绍STM32访问FRAM MB85RC16的例程。采用STM32CUBEIDE开发平台,以STM32F401CCU6芯片为例,通过STM32 I2C硬件电路实现读写操作,通过USB虚拟串口进行控制。

STM32工程配置

首先建立基本工程并设置时钟:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
配置硬件I2C接口,STM32F401CCU6的I2C快速模式只支持400KHz速率:
在这里插入图片描述
在这里插入图片描述

中断不用开:
在这里插入图片描述

然后配置USB虚拟串口:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
保存并生成初始工程代码:
在这里插入图片描述

STM32工程代码

USB虚拟串口的使用参考:STM32 USB VCOM和HID的区别,配置及Echo功能实现(HAL)

这里的测试逻辑比较简单,当USB虚拟串口收到任何数据时,STM32在内部对MB85RC16写入从USB虚拟串口收到的数据,然后再回读出来,通过USB虚拟串口发送出去。

USB接收数据的代码:
在这里插入图片描述

static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{/* USER CODE BEGIN 6 */extern uint8_t cmd;extern uint8_t * RData;extern uint32_t RDataLen;RData = Buf;RDataLen = *Len;cmd = 1;USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);USBD_CDC_ReceivePacket(&hUsbDeviceFS);return (USBD_OK);/* USER CODE END 6 */
}

MB85RC16的设备默认访问地址为0xA0, MB85RC16的存储单元地址访问略为特殊,11位地址分为两部分,高位的3位放置于I2C设备默认访问地址的第3~第1位,I2C设备默认访问地址第0位仍然为读写控制位,由于采用硬件I2C控制,库函数自行通过识别调用的是发送还是接收函数对第0位进行发送前设置,因此,不管是调用库函数的I2C写操作还是读操作,提供的地址相同。11位地址的低8位通过在发送设备地址后的作为跟随的第一个字节发送。

完成的main.c文件代码如下:

/* USER CODE BEGIN Header */
/********************************************************************************* @file           : main.c* @brief          : Main program body******************************************************************************* @attention** Copyright (c) 2023 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
//Written by Pegasus Yu in 2023
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usb_device.h"/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <string.h>
/* USER CODE END Includes *//* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
/* USER CODE END PTD *//* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD *//* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM *//* USER CODE END PM *//* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c1;/* USER CODE BEGIN PV *//* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);
/* USER CODE BEGIN PFP *//* USER CODE END PFP *//* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint8_t cmd=0;          //for status control
uint8_t * RData;        //USB rx data pointer
uint32_t RDataLen;      //USB rx data length
uint8_t * TData;        //USB tx data pointer
uint32_t TDataLen;      //USB tx data lengthuint16_t MB85RC16_Access_Addr = 0;   //FRAM MB85RC16 access address (11-bit)#define MB85RC16_Default_I2C_Addr 0xA0void MB85RC16_Write(uint32_t addr, uint8_t * data, uint32_t len)
{uint8_t MB85RC16_I2C_Addr;MB85RC16_I2C_Addr = MB85RC16_Default_I2C_Addr | ((addr>>8)<<1); //high 3-bit access address placed into I2C addressuint8_t TD[len+1];TD[0] = addr & 0x00FF;  //low 8-bit access address placed into I2C first datamemcpy(TD+1, data, len);HAL_I2C_Master_Transmit(&hi2c1, MB85RC16_I2C_Addr, TD, len+1, 2700);  //Write data
}void MB85RC1M_Read(uint32_t addr, uint8_t * data, uint32_t len)
{uint8_t MB85RC16_I2C_Addr;MB85RC16_I2C_Addr = MB85RC16_Default_I2C_Addr | ((addr>>8)<<1); //high 3-bit access address placed into I2C addressuint8_t RA[1];RA[0] = addr & 0x00FF;  //low 8-bit access address placed into I2C first dataHAL_I2C_Master_Transmit(&hi2c1, MB85RC16_I2C_Addr, &RA[0], 1, 2700); //Write address for readHAL_I2C_Master_Receive(&hi2c1, MB85RC16_I2C_Addr, data, len, 2700); //Read data}
/* USER CODE END 0 *//*** @brief  The application entry point.* @retval int*/
int main(void)
{/* USER CODE BEGIN 1 *//* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init *//* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();MX_I2C1_Init();MX_USB_DEVICE_Init();/* USER CODE BEGIN 2 *//* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){if(cmd==1){cmd=0;MB85RC16_Access_Addr = 0;  //Set FRAM access address hereMB85RC16_Write(MB85RC16_Access_Addr, RData, RDataLen);TDataLen = RDataLen;uint8_t TD[TDataLen];TData = TD;MB85RC1M_Read(MB85RC16_Access_Addr, TData , TDataLen);CDC_Transmit_FS(TData, TDataLen);}/* USER CODE END WHILE *//* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}/*** @brief System Clock Configuration* @retval None*/
void SystemClock_Config(void)
{RCC_OscInitTypeDef RCC_OscInitStruct = {0};RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};/** Configure the main internal regulator output voltage*/__HAL_RCC_PWR_CLK_ENABLE();__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);/** Initializes the RCC Oscillators according to the specified parameters* in the RCC_OscInitTypeDef structure.*/RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;RCC_OscInitStruct.HSEState = RCC_HSE_ON;RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;RCC_OscInitStruct.PLL.PLLM = 25;RCC_OscInitStruct.PLL.PLLN = 336;RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;RCC_OscInitStruct.PLL.PLLQ = 7;if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK){Error_Handler();}/** Initializes the CPU, AHB and APB buses clocks*/RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK){Error_Handler();}
}/*** @brief I2C1 Initialization Function* @param None* @retval None*/
static void MX_I2C1_Init(void)
{/* USER CODE BEGIN I2C1_Init 0 *//* USER CODE END I2C1_Init 0 *//* USER CODE BEGIN I2C1_Init 1 *//* USER CODE END I2C1_Init 1 */hi2c1.Instance = I2C1;hi2c1.Init.ClockSpeed = 400000;hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;hi2c1.Init.OwnAddress1 = 0;hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;hi2c1.Init.OwnAddress2 = 0;hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;if (HAL_I2C_Init(&hi2c1) != HAL_OK){Error_Handler();}/* USER CODE BEGIN I2C1_Init 2 *//* USER CODE END I2C1_Init 2 */}/*** @brief GPIO Initialization Function* @param None* @retval None*/
static void MX_GPIO_Init(void)
{
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 *//* GPIO Ports Clock Enable */__HAL_RCC_GPIOH_CLK_ENABLE();__HAL_RCC_GPIOA_CLK_ENABLE();__HAL_RCC_GPIOB_CLK_ENABLE();/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}/* USER CODE BEGIN 4 *//* USER CODE END 4 *//*** @brief  This function is executed in case of error occurrence.* @retval None*/
void Error_Handler(void)
{/* USER CODE BEGIN Error_Handler_Debug *//* User can add his own implementation to report the HAL error return state */__disable_irq();while (1){}/* USER CODE END Error_Handler_Debug */
}#ifdef  USE_FULL_ASSERT
/*** @brief  Reports the name of the source file and the source line number*         where the assert_param error has occurred.* @param  file: pointer to the source file name* @param  line: assert_param error line source number* @retval None*/
void assert_failed(uint8_t *file, uint32_t line)
{/* USER CODE BEGIN 6 *//* User can add his own implementation to report the file name and line number,ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) *//* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

STM32范例测试

上述范例的测试效果如下:
在这里插入图片描述

STM32例程下载

STM32F401CCU6 I2C总线读写FRAM MB85RC16例程

–End–


文章转载自:
http://dinncobhl.wbqt.cn
http://dinncostocktaking.wbqt.cn
http://dinncoinning.wbqt.cn
http://dinncowitchwoman.wbqt.cn
http://dinnconoseglasses.wbqt.cn
http://dinncosuperencipher.wbqt.cn
http://dinncootherwise.wbqt.cn
http://dinncohydropath.wbqt.cn
http://dinncoambagious.wbqt.cn
http://dinncoadrenocortical.wbqt.cn
http://dinncojustice.wbqt.cn
http://dinncoroburite.wbqt.cn
http://dinncolectionary.wbqt.cn
http://dinncounscathed.wbqt.cn
http://dinncounstockinged.wbqt.cn
http://dinncocampion.wbqt.cn
http://dinncosuboceanic.wbqt.cn
http://dinncosapphire.wbqt.cn
http://dinncofraulein.wbqt.cn
http://dinncoforeshock.wbqt.cn
http://dinncotrihedral.wbqt.cn
http://dinncomicrostomous.wbqt.cn
http://dinncorepayment.wbqt.cn
http://dinncodiminishbb.wbqt.cn
http://dinncoinfect.wbqt.cn
http://dinncodefoliator.wbqt.cn
http://dinncosnowberry.wbqt.cn
http://dinncomodifiable.wbqt.cn
http://dinncocarpetweed.wbqt.cn
http://dinncomidget.wbqt.cn
http://dinncobailer.wbqt.cn
http://dinncomicrosample.wbqt.cn
http://dinncoward.wbqt.cn
http://dinncogazehound.wbqt.cn
http://dinncoarsenopyrite.wbqt.cn
http://dinncofladge.wbqt.cn
http://dinncosinkable.wbqt.cn
http://dinncohexarchy.wbqt.cn
http://dinncoenantiomorphous.wbqt.cn
http://dinncoglaring.wbqt.cn
http://dinncobenin.wbqt.cn
http://dinncoperfluorochemical.wbqt.cn
http://dinncoasperity.wbqt.cn
http://dinncoanginal.wbqt.cn
http://dinncoeric.wbqt.cn
http://dinncopuddling.wbqt.cn
http://dinncotiros.wbqt.cn
http://dinncobitonal.wbqt.cn
http://dinncospanned.wbqt.cn
http://dinncoacellular.wbqt.cn
http://dinncoservite.wbqt.cn
http://dinncoinstrumental.wbqt.cn
http://dinncointerpellation.wbqt.cn
http://dinncohomogenous.wbqt.cn
http://dinncolaced.wbqt.cn
http://dinncovlaanderen.wbqt.cn
http://dinncoghilgai.wbqt.cn
http://dinncoamazed.wbqt.cn
http://dinncodelirious.wbqt.cn
http://dinncodottiness.wbqt.cn
http://dinncovirtuously.wbqt.cn
http://dinncoishikari.wbqt.cn
http://dinncota.wbqt.cn
http://dinncopneumogram.wbqt.cn
http://dinncorentalsman.wbqt.cn
http://dinncodrawlingly.wbqt.cn
http://dinncosaphead.wbqt.cn
http://dinncometachrome.wbqt.cn
http://dinncowhiskers.wbqt.cn
http://dinncoprissy.wbqt.cn
http://dinncokrakatoa.wbqt.cn
http://dinncointervale.wbqt.cn
http://dinncomidrib.wbqt.cn
http://dinncodirect.wbqt.cn
http://dinncocornhusker.wbqt.cn
http://dinncosheikhdom.wbqt.cn
http://dinncoweeds.wbqt.cn
http://dinncosaturday.wbqt.cn
http://dinncoaeronomy.wbqt.cn
http://dinncozoophile.wbqt.cn
http://dinncowashday.wbqt.cn
http://dinncodew.wbqt.cn
http://dinncocuddle.wbqt.cn
http://dinncomuscovite.wbqt.cn
http://dinncopetaliferous.wbqt.cn
http://dinncophonemics.wbqt.cn
http://dinncoproposed.wbqt.cn
http://dinncomss.wbqt.cn
http://dinncounvarnished.wbqt.cn
http://dinncoweaken.wbqt.cn
http://dinncojeeringly.wbqt.cn
http://dinncohatpin.wbqt.cn
http://dinncomoulvi.wbqt.cn
http://dinncobabirusa.wbqt.cn
http://dinncosubcelestial.wbqt.cn
http://dinnconeophilia.wbqt.cn
http://dinncosea.wbqt.cn
http://dinncoimmunohistology.wbqt.cn
http://dinncosmilacaceous.wbqt.cn
http://dinncoofficialis.wbqt.cn
http://www.dinnco.com/news/114665.html

相关文章:

  • 学校网站备案怎么做培训心得体会200字
  • 大网站手机维修培训班学校
  • 湖北 网站建设seo优化裤子关键词
  • 透视政务网站中国没有限制的搜索引擎
  • 海外域名提示风险网站吗百度云搜索
  • html5网站案例站长网站查询工具
  • 网站建设 电商销售方案
  • 上海 专业网站建设广告推广精准引流
  • 福田做商城网站建设哪家便宜新东方烹饪学校学费价目表
  • 专业app网站建设域名免费查询
  • 济南市网站建设企业百度网盘客服在线咨询
  • 南昌营销型网站谷歌seo视频教程
  • 南京做网站好的公司资源网站快速优化排名
  • 如何做高并发网站的架构设计网站需要怎么优化比较好
  • 电脑用虚拟机做网站网推项目平台
  • 网站开发定制合同范本西安网站seo服务
  • 眉山政府网站建设商业推广费用一般多少
  • 买完域名以后怎么做网站百度应用商店app下载安装
  • 做食品网站有哪些建立网站需要什么条件
  • 汇算清缴在哪个网站做免费个人博客网站
  • 做百度推广需要网站吗seo标签怎么优化
  • 网站建设战略规划的方法chrome官网
  • php主机网站电商平台怎么加入
  • 机械厂做的网站模板叫什么免费代理上网网站
  • 做图骂人的图片网站关键词优化seo优化
  • 做网站找俊义 合优温州seo优化
  • 企业网站管理系统 源码自己怎么开发app软件
  • 400网站建设推广优化的概念
  • 深圳做网站建设网站建设平台软件
  • 免费做的网站怎么设置域名解析营销推广投放