在线时间223 小时
UID3159710
注册时间2015-9-1
NXP金币31
TA的每日心情 | 擦汗 2017-12-29 14:09 |
---|
签到天数: 144 天 [LV.7]常住居民III
金牌会员
- 积分
- 1607
- 最后登录
- 2019-3-18
|
本帖最后由 liao122 于 2017-6-22 21:46 编辑
首先第一件事当然是收集资料
1、官网(http://mcuxpresso.nxp.com/en/welcome)下载了SDK,有IAR,keil 的,我以上传至百度网盘,有需要的可下载
2、万利网站提供的资料 (百度网盘)
3、keil 54000 系列 pack (百度网盘)
百度网盘链接: https://pan.baidu.com/s/1nvODEqP
PS: 发现用联通的4G卡上官网速度杆杆的,能500K/s的下载速度。
我发现固件不更新虚拟串口也能输出。
然后上电测试
插上USB连上电脑(板子CN1口),出现的是板子预装的演示程序,按按键led9会亮,有声音事led8会亮,串口输出检测的温度
开箱照
上电的板子
串口输出
点灯
1、没有安装LPC 54000 pack 安装包的需先安装 (以上传至百度网盘)
2、打开下载的SDK的 led例程,路径如图
3、查看LPC54114板子led IO口
在万利提供的资料有PDF的原理图
4、按照原理中的IO修改例程
BOARD_InitPins(); 函数配置led0~led7 IO
- /*FUNCTION**********************************************************************
- *
- * Function Name : BOARD_InitPins
- * Description : Configures pin routing and optionally pin electrical features.
- *
- *END**************************************************************************/
- void BOARD_InitPins(void) { /* Function assigned for the Core #0 (ARM Cortex-M4) */
- CLOCK_EnableClock(kCLOCK_Iocon); /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
- const uint32_t port0_pin0_config = (
- IOCON_PIO_FUNC1 | /* Pin is configured as FC0_RXD_SDA_MOSI */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN0_IDX, port0_pin0_config); /* PORT0 PIN0 (coords: 31) is configured as FC0_RXD_SDA_MOSI */
- const uint32_t port0_pin1_config = (
- IOCON_PIO_FUNC1 | /* Pin is configured as FC0_TXD_SCL_MISO */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN1_IDX, port0_pin1_config); /* PORT0 PIN1 (coords: 32) is configured as FC0_TXD_SCL_MISO */
-
-
- /****************************************************************************/
- // LED configured
- const uint32_t port0_pin15_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_15 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 15, port0_pin15_config); /* PORT0 PIN15 (LED1) is configured as PIO0_15 */
- const uint32_t port0_pin19_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_19 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 19, port0_pin19_config); /* PORT0 PIN19 (LED2) is configured as PIO0_19 */
- const uint32_t port0_pin22_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_22 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 22, port0_pin22_config); /* PORT0 PIN22 (LED3) is configured as PIO0_22 */
- const uint32_t port0_pin25_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_25 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 25, port0_pin25_config); /* PORT0 PIN25 (LED4) is configured as PIO0_25 */
- const uint32_t port0_pin26_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_26 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 26, port0_pin26_config); /* PORT0 PIN26 (LED5) is configured as PIO0_26 */
- const uint32_t port0_pin29_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_29 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 29, port0_pin29_config); /* PORT0 PIN29 (LED6) is configured as PIO0_29 */
- const uint32_t port0_pin30_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO0_30 */
- IOCON_PIO_I2CSLEW_GPIO | /* GPIO mode */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_I2CDRIVE_LOW | /* Low drive: 4 mA */
- IOCON_PIO_I2CFILTER_EN /* I2C 50 ns glitch filter enabled */
- );
- IOCON_PinMuxSet(IOCON, 0, 30, port0_pin30_config); /* PORT0 PIN30 (LED7) is configured as PIO0_30 */
- }
复制代码
主函数如下
- void Led(uint32_t port, uint32_t pin, uint32_t output)
- {
- gpio_pin_config_t led_config = {
- kGPIO_DigitalOutput, 0,
- };
- GPIO_PinInit(GPIO, port, pin, &led_config); //IO¿ÚÅäÖÃÊä³ö
- GPIO_WritePinOutput(GPIO, port, pin, output);
- }
- int main(void)
- {
- uint32_t port_state = 0;
- /* Define the init structure for the output LED pin*/
- gpio_pin_config_t led_config = {
- kGPIO_DigitalOutput, 0,
- };
- /* Board pin, clock, debug console init */
- /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
- CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
- /* enable clock for GPIO*/
- CLOCK_EnableClock(kCLOCK_Gpio0);
- CLOCK_EnableClock(kCLOCK_Gpio1);
- BOARD_InitPins();
- BOARD_BootClockFROHF48M();
- BOARD_InitDebugConsole();
- /* Print a note to terminal. */
- PRINTF("\r\n GPIO Driver example\r\n");
- PRINTF("\r\n The LED is taking turns to shine.\r\n");
- /* Init output LED GPIO. */
-
- Led(0,15,1);//led0~led3 ¸ßµçƽµãÁÁ
- Led(0,19,1);
- Led(0,21,1);
- Led(0,22,1);
- Led(0,25,0);//led4~led7 µÍµçƽµãÁÁ
- Led(0,26,0);
- Led(0,29,0);
- Led(0,30,0);
- while (1)
- {
- ;
- }
- }
复制代码
下载程序,效果如图
|
|