标题:
STM32+ADS1256数据采集卡程序源码
[打印本页]
作者:
3314LZP
时间:
2018-11-21 17:05
标题:
STM32+ADS1256数据采集卡程序源码
STM32采集卡程序,需要自取
STM32F103C8T6与ADS1256连线说明
F103C8T6开发板GPIOB11 --- ADS1256板子RESET 相连
F103C8T6开发板GPIOB10 --- ADS1256板子 DRDY 相连
F103C8T6开发板GPIOB12 --- ADS1256板子CS 相连
F103C8T6开发板GPIOB13 --- ADS1256板子SCLK 相连
F103C8T6开发板GPIOB14 --- ADS1256板子DOUT 相连
F103C8T6开发板GPIOB15 --- ADS1256板子DIN 相连
F103C8T6开发板GND --- ADS1256板子DGND 相连
实际测试连线图
0.png
(303.11 KB, 下载次数: 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, 下载次数: 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.51hei.com/bbs/)
Powered by Discuz! X3.1