一、 準(zhǔn)備硬件和相關(guān)知識(shí) 1. 硬件:一塊開(kāi)發(fā)板、邏輯分析儀、熱電偶(常用的K型熱電偶)、杜邦線等;
2. 相關(guān)知識(shí):VHDL基礎(chǔ)、SPI通信;
二、 max31855datasheet編程用到的部分: 1.電路連接圖
2.串行接口時(shí)序特性
3 .串口時(shí)序
4.引腳分配
5.熱電偶溫度格式
三、程序編寫(xiě) /** ****************************************************************************** * @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(); } } ……………………………………………… 四、編程中注意的問(wèn)題 把握時(shí)序圖,嚴(yán)格核準(zhǔn)。 五、訂貨選型
|