一、 准备硬件和相关知识 1. 硬件:一块开发板、逻辑分析仪、热电偶(常用的K型热电偶)、杜邦线等;
2. 相关知识:VHDL基础、SPI通信;
二、 max31855datasheet编程用到的部分: 1.电路连接图
2.串行接口时序特性
3 .串口时序
4.引脚分配
5.热电偶温度格式
三、程序编写 /** ****************************************************************************** * @file : max31855.c * @brief : MAX31855 cold-junction compensated thermocouple-to-digital * converter program body. ****************************************************************************** * * All rights reserved. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "max31855.h" #include "stm32f1xx_hal.h" /* External variables --------------------------------------------------------*/ SPI_HandleTypeDef hspi1; /* Private variables ---------------------------------------------------------*/ float tcTemp = 0, cjTemp = 0; bool tcError = false; /* Private function prototypes -----------------------------------------------*/ /** * @brief Delay about 11ns per NOP (72MHz*1.25MIPS/MHz=90MIPS) * @param None * @retval None */ static void SPI_Delay(uint32_t counter) { for(int i=0; i<counter; i++) { __NOP(); } } ……………………………………………… 四、编程中注意的问题 把握时序图,严格核准。 五、订货选型
|