你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

stm32f103c8t6不能读取ltc2400的数据

[复制链接]
vagina 提问时间:2018-10-22 18:36 /
  1. #include <string.h>
  2. //B5片选
  3. //B6数据
  4. //B7时钟
  5. #include "APP.h"
  6. #include "BSP.h"
  7. #include "BSP_tim.h"
  8. #include "HW_Config.h"
  9. #define SCK_L                GPIO_ResetBits(GPIOB, GPIO_Pin_7)
  10. #define SCK_H                GPIO_SetBits(GPIOB, GPIO_Pin_7)
  11. #define GETSDO                GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_6)
  12. #define CS_L                        GPIO_ResetBits(GPIOB, GPIO_Pin_5)
  13. #define CS_H                        GPIO_SetBits(GPIOB, GPIO_Pin_5)

  14. int VInit( void )
  15. {
  16.         GPIO_InitTypeDef GPIO_InitStructure;
  17.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  18.         GPIO_InitStructure.GPIO_Mode         =GPIO_Mode_IN_FLOATING;
  19.         GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_6;
  20.         GPIO_Init(GPIOB, &GPIO_InitStructure);
  21.         
  22.   GPIO_InitStructure.GPIO_Speed   = GPIO_Speed_50MHz;
  23.         GPIO_InitStructure.GPIO_Mode         = GPIO_Mode_Out_PP;
  24.   GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_5 | GPIO_Pin_7;
  25.         GPIO_Init(GPIOB, &GPIO_InitStructure);
  26.         return 0;
  27. }
  28. int main(void)
  29. {
  30.     uint32_t count = 0;
  31.     uint32_t len = 0;
  32.                 uint8_t a=0,b=0,c=0,d=0;
  33.     USB_Config();
  34.                 VInit();
  35.                 USB_TxWrite("initdone", 8);
  36.                 for(count=0;count<60000;count++);
  37.                 for(count=0;count<60000;count++);
  38.                 for(count=0;count<60000;count++);
  39.                 USB_TxWrite("yanshi", 6);
  40. zh:        len=0;
  41.                 CS_H;
  42.                 SCK_L;
  43.                 CS_L;
  44.                 for(count=0;count<32;count++)
  45.                 {
  46.                         len<<=1;
  47.                         SCK_H;
  48.                         len|=GETSDO;
  49.                         SCK_L;
  50.                 }
  51.                 CS_H;
  52.                 a=(len&&0xFF000000)>>24;
  53.                 b=(len&&0xFF0000)>>16;
  54.                 c=(len&&0xFF00)>>8;
  55.                 d=(len&&0xFF)>>0;
  56.                 print8(a);
  57.                 USB_TxWrite("  ", 2);
  58.                 print8(b);
  59.                 USB_TxWrite("  ", 2);
  60.                 print8(c);
  61.                 USB_TxWrite("  ", 2);
  62.                 print8(d);
  63.                 USB_TxWrite("  ", 2);
  64.                 USB_TxWrite("\r\n", 2);
  65.                
  66.                 for(count=0;count<60000;count++);
  67.                 for(count=0;count<60000;count++);
  68.                 for(count=0;count<60000;count++);
  69.                 for(count=0;count<60000;count++);
  70.                 for(count=0;count<60000;count++);
  71.                 for(count=0;count<60000;count++);
  72.                 for(count=0;count<60000;count++);
  73.                 for(count=0;count<60000;count++);
  74.                 for(count=0;count<60000;count++);
  75.                 goto zh;        
  76. }

复制代码

收藏 评论4 发布时间:2018-10-22 18:36

举报

4个回答
vagina 回答时间:2018-10-22 18:40:49
USB部分用了网上的代码 直接在usb接口输出数据
我把adc的FO接到vcc了 鄙视这论坛没有图片上传功能 还要搞啥图床 我把头像改成ltc2400框图了大家可以看下
vagina 回答时间:2018-10-22 18:43:46
输出是
00000000  00000000  00000000  00000001  
00000000  00000000  00000000  00000001  
00000000  00000000  00000000  00000001  
00000000  00000000  00000000  00000001  
无限循环 模拟输入接基准输出或者地都不会变
vagina 回答时间:2018-10-22 18:56:23
补一下将字节以二进制打印的print8函数
int printf8(uint8_t jiba)
{
        int daa;
        for(daa=7;daa>=0;daa--)
        {
        if((jiba>>daa))
                USB_TxWrite("1", 1);
        else
                USB_TxWrite("0", 1);
        }
        return 0;
}
vagina 回答时间:2018-10-22 21:28:23
这个代码有很多错误,已改好,能获取数据了,不过数据有很大问题正在修正

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版