2020-02-11 10:09发布
FSL_TICS_Robin 发表于 2015-10-26 09:42 16bit MCU的问题,建议在飞思卡尔官方论坛的S12 / MagniV Microcontrollers版块发帖提问,用英文简单描述一 ...
最多设置5个标签!
发帖了,没人回答。我看好多都是过了好多天也没任何回复的。
AD部分代码大概如下,仿真的时候,进入MCUregester,AD转换就停止
- #include <hidef.h> /* common defines and macros */
- #include "derivative.h" /* derivative-specific definitions */
- void AutoEle_InitPLL (void)
- {
- CLKSEL &= ~(0x80); //Select OSCCLK as MCU clock
- REFDV = 0xC0; //FREF = Fosc / (REFDIV +1), FEFFRQ=11, REFDIV=0
- SYNR = 0xC2; //FVCO = 2 * Fref * (SYNR + 1)
- POSTDIV = 0; //FPLL = FVCO / (2 * POSTDIV)
- while (!CRGFLG_LOCK) ; // Wait unitl PLL locked
- CLKSEL |= 0x80; //Select PLLCLK as MCU clock
- }
- /************************************************************************
- *FUNCTION NAME:AutoEle_EP100_ADInit
- *功能: 初始化AD模块
- *参数:void
- *返回值void
- ************************************************************************/
- void AutoEle_EP100_ADInit(void)
- {
- /* AD0 AN0-AN15 */
- ATD0CTL0 = 15; //回环通道
- ATD0CTL1 = 0x2F; //外部触发源,10位分辨率
- ATD0CTL2 = 0x40; //CCF位快速清除,及中断使能配置
- ATD0CTL3 = 0x80 | (0 << 3); //右对齐,转换序列长度为3,非FIFO模式
- ATD0CTL4 = 0x57; //采样时间8AD时钟周期,总线时钟分频 Fad= Fbus/(2*(Prs[4~0] + 1)) 1M ,
- ATD0CMPE = 0x0; //比较功能关闭 2bytes
- ATD0DIEN = 0x0; //Disable digital input buffer to ANx pin 2bytes
- ATD0CTL5 = 0x10;
- /* AD1 AN16-AN23 */
- ATD1CTL0 = 7; //回环通道
- ATD1CTL1 = 0x2F; //外部触发源,10位分辨率
- ATD1CTL2 = 0x40;
- ATD1CTL3 = 0x80 | (8 << 3); //右对齐,转换序列长度为3,非FIFO模式
- ATD1CTL4 = 0x57; //采样时间8AD时钟周期,总线时钟分频 Fad= Fbus/(2*(Prs[4~0] + 1)) 1M ,
- ATD1CMPE = 0x0; //比较功能关闭 2bytes
- ATD1DIEN = 0x18; //Disable digital input buffer to ANx pin 2bytes
- ATD1CTL5 = 0x10;
- }
- void main(void)
- {
- /* put your own code here */
- AutoEle_EP100_ADInit();
- AutoEle_EP100_ADInit();
-
-
- EnableInterrupts;
- for(;;)
- {
- if ((ATD0STAT0_SCF == 0) || (ATD1STAT0_SCF == 0))
- {
-
- }
- else
- {
- ATD0CTL5 = 0x10; //启动转换
- ATD1CTL5 = 0x10; //启动转换
- }
-
- _FEED_COP(); /* feeds the dog */
- } /* loop forever */
- /* please make sure that you never leave main */
- }
复制代码一周热门 更多>