3094 views|2 replies

67

Posts

2

Resources
The OP
 

1. [Learning LPC1768 library functions] LED experiment [Copy link]

void LED_Config(void)
{
// The first step is to turn on the GPIO peripheral clock power. Only when it is turned on can the related GPIO registers be operated .
Chip_GPIO_Init(LPC_GPIO); //Peripheral clock power
//The second step is to set the GPIO pin to normal GPIO function.
Chip_IOCON_PinMux(LPC_IOCON, 2, 0, IOCON_MODE_INACT, IOCON_FUNC0);
//IOCON_FUNC0 sets P2.0 to GPIO function, IOCON_MODE_INACT (turn off the pull-up and pull-down functions)
Chip_IOCON_PinMux(LPC_IOCON, 2, 1, IOCON_MODE_INACT, IOCON_FUNC0); //IOCON_FUNC0 sets P2.1 to GPIO function
Chip_IOCON_PinMux(LPC_IOCON, 2, 2, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_IOCON_PinMux(LPC_IOCON, 2, 3, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_IOCON_PinMux(LPC_IOCON, 2, 4, IOCON_MODE_INACT,
Chip_IOCON_PinMux(LPC_IOCON, 2, 5, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_IOCON_PinMux(LPC_IOCON, 2, 6, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_IOCON_PinMux(LPC_IOCON, 2, 7, IOCON_MODE_INACT, IOCON_FUNC0); //Set P2.7 to GPIO function //The third step is
to set the output mode, because it is to control peripheral devices, set it to output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 0, true); //Set P2.0 output mode true, output mode false input mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 1, true);//Set output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 2, true);//Set output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 3, true);//Set output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 4, true);//Set output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 5, true);//Set output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 6, true);//Set output mode
Chip_GPIO_SetPinDIR(LPC_GPIO,2, 7, true);//Set output mode
//The fourth step is to set the output low level P2.0~P2.7.
Chip_GPIO_SetPortValue(LPC_GPIO,2,0XFFFFFF00);//Set the output low level P2.0~P2.7
}


The following two functions are bit manipulation functions that control the output high and low levels. They have the same effect as the Chip_GPIO_SetPortValue() function.
Chip_GPIO_SetPinOutHigh(LPC_GPIO,2,0)//Set P2.0 output high level
Chip_GPIO_SetPinOutLow(LPC_GPIO,2,0)//Set P2.0 output low level

【01】LPC1768_LED实验.rar (241.61 KB, downloads: 17)


This content is originally created by EEWORLD forum user cxmdz . If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

This post is from NXP MCU

Latest reply

PJB
Thanks for sharing, I learned a lot   Details Published on 2019-11-12 12:36
 

79

Posts

0

Resources
2
 

Give it a thumbs up to support the OP to continue updating

This post is from NXP MCU
 
 
 

7

Posts

0

Resources
3
 

Thanks for sharing, I learned a lot

This post is from NXP MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list