在线时间372 小时
UID3135871
注册时间2016-10-9
NXP金币20
TA的每日心情 | 怒 2024-2-5 12:06 |
---|
签到天数: 627 天 [LV.9]以坛为家II
版主
- 积分
- 4429
- 最后登录
- 2024-2-5
|
芯片寄存器太多,记不住,去查手册又大大降低效率,怎么办?其实多加芯片制造商都推出自己的外设配置工具。我使用过最早的就是新华龙的C8051系列,当时就有引脚配置并生成代码的工具了。这几年软件生态越来越向应用层发展,底层代码的具体编写则是被各种库或者配置工具直接生成代码所替代了。有人说,这样层层封装,会降低代码的执行效率和增加代码结构和大小的臃肿。其实在今天这个片上FLASH都很大,速度都很快的年代,这些都不算什么大问题了。ST,NXP,Microchip等均有自己的外设配置工具废话不多说,下面开始说说我们MC56F83789DSC的外设配置工具说起。本来想用PE进行配置,奈何PE不支持最新出的83XXX系列的芯片,官方介绍了一个叫做GCT的外设配置工具。我们今天就用它来实现。
今天所讲均能在上面的说明文档里面找到,还更详细,奈何是英文版本。首先安装Code Warror,那就不用多说了。然后安装FMASTER(FMASTERSW30.exe),主要用它的一些头文件(不免费,需要证书,但官方提供LITE版本的证书),其次安装DSC56800EX_Quick_Start(文中短称GCT)执行文件。
安装完成后,打开CodeWarror安装对GCT这个外部工具支持的PACK,即基于GCT的工程生成向导:
向导装完后,我们配置外部工具:
配置好后,我们现用对应的向导生成一个GCT工程:
选择工程的属性,配置将要调用的GCT文件路径:
设置快速调用最后一次工具的快捷键:
生成的程序结构,其中appconfig.h头文件为外部配置工具输出文件:
打开配置好的外部GCT:
配置工具页面,用过其他家的,应该感觉都大同小异:
我们要配置4个LED,并让它们闪烁。4个LED引脚对应F8~P11:
配置好,直接点击保存,工程中的appconfig.h就会更新:
我们修改main函数:
- /* required DSP56F800E_Quick_Start header */
- #include "qs.h"
- /* low-level driver headers for each module used */
- #include "occs.h"
- #include "sys.h"
- #include "adc12.h"
- #include "cop.h"
- #include "crc.h"
- #include "dac.h"
- #include "dma.h"
- #include "fcan.h"
- #include "ftfe.h"
- #include "gpio.h"
- #include "hscmp.h"
- #include "iic.h"
- #include "intc.h"
- #include "intctarget.h"
- #include "mcm.h"
- #include "pmc.h"
- #include "pwm.h"
- #include "pit.h"
- #include "qtimer.h"
- #include "sci.h"
- #include "scihl.h"
- #include "spi.h"
- #include "xbar.h"
- #include "freemaster.h"
- /* local prototypes */
- #define LED_RED_ON ioctlGPIO_CLEAR_PIN(GPIO_F,BIT_8)
- #define LED_RED_OFF ioctlGPIO_SET_PIN(GPIO_F,BIT_8)
- #define LED_GREEN_ON ioctlGPIO_CLEAR_PIN(GPIO_F,BIT_9)
- #define LED_GREEN_OFF ioctlGPIO_SET_PIN(GPIO_F,BIT_9)
- #define LED_BLUE_ON ioctlGPIO_CLEAR_PIN(GPIO_F,BIT_10)
- #define LED_BLUE_OFF ioctlGPIO_SET_PIN(GPIO_F,BIT_10)
- #define LED_YELLOW_ON ioctlGPIO_CLEAR_PIN(GPIO_F,BIT_11)
- #define LED_YELLOW_OFF ioctlGPIO_SET_PIN(GPIO_F,BIT_11)
- void my_delay_us(UWord16 delay)
- {
- while(delay--)
- {
- archDelay(100);
- }
- }
- void my_delay_ms(UWord16 delay)
- {
- while(delay--)
- {
- my_delay_us(1000);
- }
- }
- /*
- * The main function is invoked from the startup code after
- * key device resources (PLL, memory) are initialised.
- *
- */
- void main (void)
- {
- /* initialise SYS module */
- ioctl(SYS, SYS_INIT, NULL);
- /* configure COP module */
- ioctl(COP, COP_INIT, NULL);
-
- /* configure all GPIO modules */
- ioctl(GPIO, GPIO_INIT_ALL, NULL);
- /*
- * TODO: put your other module initialisation calls here
- * e.g. ioctl(SCI, SCI_INIT, NULL)
- *
- */
- /* initialise interrupt controller and enable interrupts */
- ioctl(INTC, INTC_INIT, NULL);
- archEnableInt();
- /*
- * TODO: perform additional initialisations here
- *
- */
- while(1)
- {
- /*
- * TODO: put your main-loop code here
- *
- */
- LED_RED_ON;
- LED_GREEN_ON;
- LED_BLUE_ON;
- LED_YELLOW_ON;
- //archDelay(300000);
- my_delay_ms(300);
- LED_RED_OFF;
- LED_GREEN_OFF;
- LED_BLUE_OFF;
- LED_YELLOW_OFF;
- //archDelay(300000);
- my_delay_ms(300);
- /* feed the watchdog periodically */
- ioctl(COP, COP_CLEAR_COUNTER, NULL);
- }
- }
复制代码
编译下载无误,4LED闪烁。
quick start这一套SDK的架构还是比较有意思的,感兴趣的可以看它的使用指导,很详细。
这样大大简化了开发流程,值得拥有。
DSC56800EXQSUG(DSC快速配置工具使用说明).pdf
(4.14 MB, 下载次数: 23)
|
|