|
高精度DAC轉(zhuǎn)換模塊,可用于DIY程控電源,程序可直接使用(TLV5608)。如使用TLV5610,請自行閱讀IC資料,做微小更改。
單片機(jī)源程序如下:
- #include <stdio.h>
- #include <string.h>
- #include "stm32f10x.h"
- #include "stm32f10x_it.h"
- #include "io.h"
- //#include "key.h"
- #include "delay.h"
- //#include "timer.h"
- #include "usart.h"
- #include "adc.h"
- //#include "24cxx.h"
- //#include "menu.h"
- #include "TLV56xx.H"
- void Uart1_PutString(char* buf,u8 len );
- u8 Uart1_PutChar(u8 ch);
- u8 Uart1_recChar(void);
- void judge_command(void);
- void manul_test(void);
- void auto_test(void);
- void debug_test(void);
- void emerg(void);
- //*DO01ON#----6
- //DO01OFF---7
- //uchar command_data[7];
- //uchar RX_dat;
- int STEP_flag;
- //u8 count;
- void NVIC_Configuration(void)
- {
- NVIC_InitTypeDef NVIC_InitStructure;
- /* Configure one bit for preemption priority */
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
- /* Enable the UART4 Interrupt */
- NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 6;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
- /* Enable the UART5 Interrupt */
- NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
- //Enable DMA2 Channel3 Interrupt
- // NVIC_InitStructure.NVIC_IRQChannel = DMA2_Channel3_IRQn;
- // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
- // NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
- // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- // NVIC_Init(&NVIC_InitStructure);
- }
- void SysInit (void)
- {
- SystemInit();//系統(tǒng)時鐘配置 配置為72MHZ
- delay_init();//延時函數(shù)初始化
- NVIC_Configuration();
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
- IO_Init();
- //TIM2_Int_Init(99,71);//1Mhz的計數(shù)頻率,計數(shù)到100為0.1ms
- //TIM3_Int_Init(99,7199);//10Khz的計數(shù)頻率,計數(shù)到100為10ms
- //Adc_Init();
- Usart_Init();
- DAC_Tlv56xx_Init();
- }
- int main(void)
- {
- // int flag1,flag2,flag3,flag4;
- //flag1=0,flag2=0,flag3=0,flag4=0;
- //float LDR1Adc,LDR2Adc;
- SysInit();
- delay_ms(1000);
-
- STEP_flag=0;
-
-
- delay_ms(180);
- while(1)
- {
- // Usart4_SendStr("OK\r\n");
- delay_ms(1000);
- //auto_test();
- //printf("%d\n",bh_data_read());
- // delay_ms(16);
- }
- }
- void auto_test(void) //
- {
- //unsigned char j;
-
-
- }
復(fù)制代碼
所有資料51hei提供下載:
TLV5608模塊檢測程序驗證版.7z
(218.95 KB, 下載次數(shù): 85)
2019-11-10 02:31 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|
評分
-
查看全部評分
|