-
Notifications
You must be signed in to change notification settings - Fork 65
NXP LPC176x: Customizing
µCNC for LPC176x can be configured/customized to fit different LPC176x powered boards other than Panucatt Re-Arm board
Jump to section
µCNC for LPC176x can be customized either using the Web Config Tool or by manually modifing the source code files. For the latest method most configurations and pin assigning should be done in the corresponding boardmap file inside the uCNC/src/hal/boards/LPC176x/ directory and then the respective board file.
µCNC for LPC176x is like for AVR but takes an extra step if you are using a board with a different LPC176x flavor other then the LPC1768 used in the Panucatt Re-Arm board. It's necessary to create the boiler-plate project to fit your particular MCU. The Re-Arm source code is a good example on how to implement this. It's mostly written in plain C and it's a mix of bare-metal and HAL middleware. The only stack used is the tinyUSB library for the USB VCP port that works on a wide range of MCU's. The pinout configuration follows (almost all of) the Re-Arm for RAMPS pinout.
An HAL pin need to be mapped to a physical IO pin. The way this is done is by defining the IO PORT and BIT. This must be performed for every used pin This is similar to the general customization instructions
//set pin 2.1 as STEP0 (output pin)
#define STEP0_BIT 1 // assigns STEP0 pin
#define STEP0_PORT 2 // assigns STEP0 port
//set pin 1.24 as LIMIT_X (input pin)
#define LIMIT_X_BIT 24 // assigns LIMIT_X pin
#define LIMIT_X_PORT 1 // assigns LIMIT_X port
//set pin 2.4 as PWM0 (pwm output pin)
#define PWM1_BIT 4 // assigns PWM1 pin
#define PWM1_PORT 2 // assigns PWM1 pin
All input pins can have a weak pull-up activated to drive them high if unconnected. This is similar to the general customization instructions
All pins all repeatedly read by a soft polling routine. But for special function pins an interrupt driven event to force a reading and respective action can be also activated. This causes the response to be immediate and not depend on the pin reading routine cycle. LPC176x has 2 Interrupt on change Ports (0 and 2) that can enabled. For Re-Arm the pin mapping can be checked here.
This is similar to the general customization instructions
This is similar to the general customization instructions
To configure the pwm ouput, the used channel be supplied (besides the normal pin definition). To find the used channel register and timer we must check the MCU datasheet. Looking at the pin mapping for Re-Arm and the datasheet and knowing that we are going to use pin 2.5 has the spindle pwm control we can see that the pwm on that pin uses Channel 6 of the PWM generator.
/Setup PWM
#define PWM0_BIT 5 //assigns PWM0 pin
#define PWM0_PORT 2 //assigns PWM0 pin
#define PWM0_CHANNEL 6
Not implemented yet.
This is similar to the general customization instructions
This is similar to the general customization instructions
µCNC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. µCNC is distributed WITHOUT ANY WARRANTY.
Also without the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
µCNC Wiki
- Home
- Basic user guide
- Porting µCNC and adding custom HAL
- Customizing the HAL file
- Adding custom Tools and Modules to µCNC
- FAQ
µCNC for ALL MCU
µCNC for AVR
µCNC for STM32F1 and STM32F4
µCNC for SAMD21
µCNC for ESP8266
µCNC for ESP32
µCNC for NXP LPC176x
µCNC for NXP RP2040