標題:
STM32+ADS1256數(shù)據(jù)采集卡程序源碼
[打印本頁]
作者:
3314LZP
時間:
2018-11-21 17:05
標題:
STM32+ADS1256數(shù)據(jù)采集卡程序源碼
STM32采集卡程序,需要自取
STM32F103C8T6與ADS1256連線說明
F103C8T6開發(fā)板GPIOB11 --- ADS1256板子RESET 相連
F103C8T6開發(fā)板GPIOB10 --- ADS1256板子 DRDY 相連
F103C8T6開發(fā)板GPIOB12 --- ADS1256板子CS 相連
F103C8T6開發(fā)板GPIOB13 --- ADS1256板子SCLK 相連
F103C8T6開發(fā)板GPIOB14 --- ADS1256板子DOUT 相連
F103C8T6開發(fā)板GPIOB15 --- ADS1256板子DIN 相連
F103C8T6開發(fā)板GND --- ADS1256板子DGND 相連
實際測試連線圖
0.png
(303.11 KB, 下載次數(shù): 44)
下載附件
2018-11-21 18:00 上傳
單片機源程序如下:
#include "stm32f10x.h"
#include "stm32_eval.h"
#include "flash.h"
#include "delay.h"
#include "ADS1256.h"
#include <stdio.h>
/** @addtogroup STM32F10x_StdPeriph_Examples
* @{
*/
/** @addtogroup USART_Printf
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Values magic to the Board keys */
#define NOKEY 0
#define KEY1 1
#define KEY2 2
#define KEY3 3
#define KEY4 4
unsigned char data[16];
/* Private function prototypes -----------------------------------------------*/
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/* Private functions ---------------------------------------------------------*/
void Init_UART2()
{
USART_InitTypeDef USART_InitStructure;
/* USARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
STM_EVAL_COMInit(COM1, &USART_InitStructure);
}
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
unsigned char i=0;
long ulResult;
long double ldVolutage;
Init_UART2();
Init_ADS1256_GPIO(); //初始化ADS1256 GPIO管腳
Delay(0x1ffFF);
GPIO_SetBits(GPIOB, GPIO_Pin_11 );
ADS1256_Init();
while(1)
{
for(i = 0;i < 8;i++)
{
ulResult = ADS_sum( (i << 4) | ADS1256_MUXN_AINCOM);
//ulResult = ADS_sum( ADS1256_MUXP_AIN0 | ADS1256_MUXN_AINCOM);
if( ulResult & 0x800000 )
{
ulResult = ~(unsigned long)ulResult;
ulResult &= 0x7fffff;
ulResult += 1;
ulResult = -ulResult;
}
ldVolutage = (long double)ulResult*0.59604644775390625;
printf("第%d通道:",(i & 0x07)?(i & 0x07) - 1:7);
printf("%lf",ldVolutage); //double
printf("uV\r");
//printf("%x",(unsigned long)ulResult);//16
Delay(0x3fFFF);
}
printf("\n");
// printf("123456\n");
}
}
/**
* @brief Retargets the C library printf function to the USART.
* @param None
* @retval None
*/
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the USART */
USART_SendData(EVAL_COM1, (uint8_t) ch);
/* Loop until the end of transmission */
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
return ch;
}
#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 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) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
復制代碼
所有資料51hei提供下載:
STM32F103C8T6測試OK.rar
(5.14 MB, 下載次數(shù): 185)
2018-11-21 18:02 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
lls5201
時間:
2019-3-22 09:33
參考一下,謝謝
作者:
yyjzd0414
時間:
2019-4-17 13:10
參考學習,多謝
作者:
wanganlong
時間:
2019-4-24 14:38
這個資料挺好的
作者:
aidianzi
時間:
2019-7-13 12:11
這種串口的低速還行 高速就不好使了吧
作者:
微軟如果
時間:
2019-7-26 13:00
這個程序為什么換成STM32f10xZET就用不了
作者:
微軟如果
時間:
2019-7-27 11:35
不能用的程序能不能注明一下僅供參考
作者:
just_doing
時間:
2020-5-11 14:45
需要用這個
作者:
bdwang8901
時間:
2020-5-20 13:41
謝謝分享
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1