找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2930|回复: 3
收起左侧

一款DAC模块(TLV5608&TLV5610)STM32源程序

[复制链接]
ID:636709 发表于 2019-11-6 16:10 | 显示全部楼层 |阅读模式
高精度DAC转换模块,可用于DIY程控电源,程序可直接使用(TLV5608)。如使用TLV5610,请自行阅读IC资料,做微小更改。

单片机源程序如下:
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "stm32f10x.h"
  4. #include "stm32f10x_it.h"
  5. #include "io.h"
  6. //#include "key.h"
  7. #include "delay.h"
  8. //#include "timer.h"
  9. #include "usart.h"
  10. #include "adc.h"
  11. //#include "24cxx.h"         
  12. //#include "menu.h"
  13. #include "TLV56xx.H"
  14. void Uart1_PutString(char* buf,u8 len );
  15. u8 Uart1_PutChar(u8 ch);
  16. u8 Uart1_recChar(void);
  17. void judge_command(void);
  18. void manul_test(void);
  19. void auto_test(void);
  20. void debug_test(void);
  21. void emerg(void);
  22. //*DO01ON#----6
  23. //DO01OFF---7
  24. //uchar command_data[7];

  25. //uchar RX_dat;
  26. int STEP_flag;

  27. //u8 count;

  28. void NVIC_Configuration(void)
  29. {
  30.     NVIC_InitTypeDef NVIC_InitStructure;
  31.     /* Configure one bit for preemption priority */
  32.     NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
  33.     /* Enable the UART4 Interrupt */
  34.     NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;
  35.     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
  36.     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 6;
  37.     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  38.     NVIC_Init(&NVIC_InitStructure);
  39.     /* Enable the UART5 Interrupt */
  40.     NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn;
  41.     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
  42.     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
  43.     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  44.     NVIC_Init(&NVIC_InitStructure);
  45.     //Enable DMA2 Channel3 Interrupt
  46. //    NVIC_InitStructure.NVIC_IRQChannel = DMA2_Channel3_IRQn;
  47. //    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  48. //    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  49. //    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  50. //    NVIC_Init(&NVIC_InitStructure);
  51. }


  52. void SysInit (void)
  53. {        
  54.         SystemInit();//系统时钟配置 配置为72MHZ
  55.         delay_init();//延时函数初始化        
  56.         NVIC_Configuration();
  57.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  58.         IO_Init();
  59.         //TIM2_Int_Init(99,71);//1Mhz的计数频率,计数到100为0.1ms
  60.         //TIM3_Int_Init(99,7199);//10Khz的计数频率,计数到100为10ms
  61.         //Adc_Init();
  62.         Usart_Init();
  63.         DAC_Tlv56xx_Init();
  64. }

  65. int main(void)
  66. {
  67. //        int flag1,flag2,flag3,flag4;
  68.         //flag1=0,flag2=0,flag3=0,flag4=0;
  69.         //float LDR1Adc,LDR2Adc;        

  70.         SysInit();
  71.         delay_ms(1000);
  72.         

  73. STEP_flag=0;
  74.         
  75.         
  76.         delay_ms(180);
  77.         while(1)
  78.         {
  79.    //        Usart4_SendStr("OK\r\n");
  80.                         delay_ms(1000);
  81.                 //auto_test();
  82.                 //printf("%d\n",bh_data_read());
  83.         //        delay_ms(16);
  84.         }               

  85.         }


  86. void auto_test(void)         //
  87. {
  88.         //unsigned char j;
  89.         
  90.         



  91. }
复制代码

所有资料51hei提供下载:
TLV5608模块检测程序验证版.7z (218.95 KB, 下载次数: 80)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:384522 发表于 2020-7-17 10:00 | 显示全部楼层
mark
回复

使用道具 举报

ID:345283 发表于 2021-9-14 14:17 | 显示全部楼层
TLV5608的程序,用IO模拟SPI,谢谢分享
回复

使用道具 举报

ID:1067637 发表于 2023-3-21 16:33 | 显示全部楼层
剛好需要TLV5610的程序,可以拿來參考,謝謝分享~~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表