Demo entry 6666542

main.c

   

Submitted by Tiantian on Nov 30, 2017 at 14:11
Language: C. Code size: 850 Bytes.

#include "stm32f10x.h"
#include "adc.h"
#include "dma.h"
#include "nixie_tubes.h"
#include "tim.h"
#include "usart.h"
#include "led.h"
#include "stdio.h"


#define ADC_DATA_LEN 1

USART_Data data;

int main()
{
	data.flag = 1;													
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	Adc1_Init();
	Dma_Init((u32) &(ADC1->DR), (u32) &(data.dint), ADC_DATA_LEN);
	USART3_Init(115200);
	USART_NVIC_init();
	Tim2_DelayMs_Init(500);
	
	NixieTube_Init();
	Tim3_Display_Init();

	TIM_Cmd(TIM2, ENABLE);
	TIM_Cmd(TIM3, ENABLE);
	
	while(1)
	{
		while(data.flag == 0);					//Wait until data flag was set
		sprintf(data.dchar, "%4d", data.dint);	//Transform the type of data from int into 4 characters
		Usart_send_datas(data.dchar);			//Send data.dchar to USART3
		data.flag = 0;							//Reset data flag
	}
	
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).