收到开发板,一直没有时间开发,只是详细阅读了开发板资料,感受到了此款单片机丰富的资源。明天我得抽时间跑跑我的ADC采集程序,看它做RMS运算的时间要多长。
连接上了,做了个流水灯测试了IO口,同时用定时器做了1MS的中断,用来计时。其它的,像ADC实现,我会接着完成。不过我发现这个工具真是好用,用它生成的模块,只要在里面增加你自己的代码就可以,真方便,不错的开发环境。下面展示下我的实验结果及代码。
附上我的程序:
void main(void)
{
/* Start user code. Do not edit comment generated here */
unsigned char i;
SystemInit();
SystemTime = 0;
while (1U)
{
for( i =0; i < 8; i ++)
{
P7 =( 1 << i);
DelayNms(500);
}
//Delay(60000);
}
/* End user code. Do not edit comment generated here */
}
void SystemInit()
{
// WDT_Init(); //关闭看门狗
CLOCK_Init(); //时钟设定
//CG_ReadResetSource();
PORT_Init(); //初始化P7口为输出
TAU0_Init(); //定时器打开
TAU0_Channel0_Start(); //启动定时器
SAU0_Init(); //串口初始化
UART0_Start(); //打开UART0
//TAU0_Init();
}
void CLOCK_Init(void)
{
/* Set fMX */
CMC = _00_CG_HISYS_PORT | _00_CG_SUB_PORT | _00_CG_SYSOSC_DEFAULT | _00_CG_SUBMODE_DEFAULT;
MSTOP = 1U;
/* Set fMAIN */
MCM0 = 0U;
/* Set fSUB */
XTSTOP = 1U;
OSMC = _10_CG_RTC_CLK_FIL;
/* Set fCLK */
CSS = 0U;
/* Set fIH */
HIOSTOP = 0U;
}
*/
void PORT_Init(void)
{
P2 = _00_Pn0_OUTPUT_0 | _00_Pn1_OUTPUT_0 | _00_Pn2_OUTPUT_0 | _00_Pn3_OUTPUT_0 | _10_Pn4_OUTPUT_1 | _00_Pn5_OUTPUT_0 | _40_Pn6_OUTPUT_1 | _00_Pn7_OUTPUT_0;
P5 = _00_Pn0_OUTPUT_0 | _00_Pn1_OUTPUT_0 | _00_Pn2_OUTPUT_0 | _00_Pn3_OUTPUT_0 | _00_Pn4_OUTPUT_0 | _00_Pn5_OUTPUT_0;
P7 = _00_Pn0_OUTPUT_0 | _00_Pn1_OUTPUT_0 | _00_Pn2_OUTPUT_0 | _00_Pn3_OUTPUT_0 | _00_Pn4_OUTPUT_0 | _00_Pn5_OUTPUT_0 | _00_Pn6_OUTPUT_0 | _80_Pn7_OUTPUT_1;
PM2 = _00_PMn0_MODE_OUTPUT | _00_PMn1_MODE_OUTPUT | _00_PMn2_MODE_OUTPUT | _00_PMn3_MODE_OUTPUT | _00_PMn4_MODE_OUTPUT | _00_PMn5_MODE_OUTPUT | _00_PMn6_MODE_OUTPUT | _00_PMn7_MODE_OUTPUT;
PM5 = _00_PMn0_MODE_OUTPUT | _00_PMn1_MODE_OUTPUT | _00_PMn2_MODE_OUTPUT | _00_PMn3_MODE_OUTPUT | _00_PMn4_MODE_OUTPUT | _00_PMn5_MODE_OUTPUT | _C0_PM5_DEFAULT;
PM7 = _00_PMn0_MODE_OUTPUT | _00_PMn1_MODE_OUTPUT | _00_PMn2_MODE_OUTPUT | _00_PMn3_MODE_OUTPUT | _00_PMn4_MODE_OUTPUT | _00_PMn5_MODE_OUTPUT | _00_PMn6_MODE_OUTPUT | _00_PMn7_MODE_OUTPUT;
}
void TAU0_Init(void)
{
TAU0EN = 1U; /* supplies input clock */
TPS0 = _0000_TAU_CKM0_FCLK_0 | _0000_TAU_CKM1_FCLK_0 | _0000_TAU_CKM2_FCLK_1 | _0000_TAU_CKM3_FCLK_8;
/* Stop all channels */
TT0 = _0001_TAU_CH0_STOP_TRG_ON | _0002_TAU_CH1_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON | _0008_TAU_CH3_STOP_TRG_ON | _0010_TAU_CH4_STOP_TRG_ON | _0020_TAU_CH5_STOP_TRG_ON | _0040_TAU_CH6_STOP_TRG_ON | _0080_TAU_CH7_STOP_TRG_ON | _0200_TAU_CH1_H8_STOP_TRG_ON | _0800_TAU_CH3_H8_STOP_TRG_ON;
/* Mask channel 0 interrupt */
TMMK00 = 1U; /* disable INTTM00 interrupt */
TMIF00 = 0U; /* clear INTTM00 interrupt flag */
/* Mask channel 1 interrupt */
TMMK01 = 1U; /* disable INTTM01 interrupt */
TMIF01 = 0U; /* clear INTTM01 interrupt flag */
/* Mask channel 1 higher 8 bits interrupt */
TMMK01H = 1U; /* disable INTTM01H interrupt */
TMIF01H = 0U; /* clear INTTM01H interrupt flag */
/* Mask channel 2 interrupt */
TMMK02 = 1U; /* disable INTTM02 interrupt */
TMIF02 = 0U; /* clear INTTM02 interrupt flag */
/* Mask channel 3 interrupt */
TMMK03 = 1U; /* disable INTTM03 interrupt */
TMIF03 = 0U; /* clear INTTM03 interrupt flag */
/* Mask channel 3 higher 8 bits interrupt */
TMMK03H = 1U; /* disable INTTM03H interrupt */
TMIF03H = 0U; /* clear INTTM03H interrupt flag */
/* Mask channel 4 interrupt */
TMMK04 = 1U; /* disable INTTM04 interrupt */
TMIF04 = 0U; /* clear INTTM04 interrupt flag */
/* Mask channel 5 interrupt */
TMMK05 = 1U; /* disable INTTM05 interrupt */
TMIF05 = 0U; /* clear INTTM05 interrupt flag */
/* Mask channel 6 interrupt */
TMMK06 = 1U; /* disable INTTM06 interrupt */
TMIF06 = 0U; /* clear INTTM06 interrupt flag */
/* Mask channel 7 interrupt */
TMMK07 = 1U; /* disable INTTM07 interrupt */
TMIF07 = 0U; /* clear INTTM07 interrupt flag */
/* Set INTTM00 high priority */
TMPR100 = 0U;
TMPR000 = 0U;
/* Channel 0 used as interval timer */
TMR00 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED;
TDR00 = _7CFF_TAU_TDR00_VALUE;
TO0 &= ~_0001_TAU_CH0_OUTPUT_VALUE_1;
TOE0 &= ~_0001_TAU_CH0_OUTPUT_ENABLE;
}
void TAU0_Channel0_Start(void)
{
TMIF00 = 0U; /* clear INTTM00 interrupt flag */
TMMK00 = 0U; /* enable INTTM00 interrupt */
TS0 |= _0001_TAU_CH0_START_TRG_ON;
}
#pragma vector = INTTM00_vect
__interrupt void MD_INTTM00(void)
{
/* Start user code. Do not edit comment generated here */
TAU0_Channel0_Start();
SystemTime ++;
/* End user code. Do not edit comment generated here */
}
/* Start user code for adding. Do not edit comment generated here */
unsigned long SystemTime = 0;
void DelayNms(unsigned int i)
{
unsigned long time;
time = SystemTime;
while((SystemTime - time ) < i);
}
/* End user code. Do not edit comment generated here */
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【笔记】生成报错synthdesignERROR被打赏50分 | |
【STM32H7S78-DK评测】LTDC+DMA2D驱动RGBLCD屏幕被打赏50分 | |
【STM32H7S78-DK评测】Coremark基准测试被打赏50分 | |
【STM32H7S78-DK评测】浮点数计算性能测试被打赏50分 | |
【STM32H7S78-DK评测】Execute in place(XIP)模式学习笔记被打赏50分 | |
每周了解几个硬件知识+buckboost电路(五)被打赏10分 | |
【换取逻辑分析仪】RA8 PMU 模块功能寄存器功能说明被打赏20分 | |
野火启明6M5适配SPI被打赏20分 | |
NUCLEO-U083RC学习历程2-串口输出测试被打赏20分 | |
【笔记】STM32CUBEIDE的Noruletomaketarget编译问题被打赏50分 |