void app_setup_pin(void) { /* Enable SWM clock before altering SWM */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); Chip_GPIO_SetPinDIR(LPC_GPIO_PORT, 0, 4, false);//Push botton SW1 = PIO0_04 Chip_GPIO_SetPinDIR(LPC_GPIO_PORT, 0, 16, true);//green led act low = PIO0_16 /* Connect SCT input 0 to SW1 pin PIO0_04 */ Chip_SWM_DisableFixedPin(SWM_FIXED_ADC11);//PIO_04 disable Chip_SWM_MovablePinAssign(SWM_SCT_IN0_I, 4);//=SW1=Wake texted Chip_INMUX_SetSCTInMux(LPC_INMUX, SCT_INMUX_0, SCT_INP_IN0 );//?? /* Connect SCT output 0 to LED pin PIO_16 */ Chip_SWM_MovablePinAssign(SWM_SCT_OUT0_O, 16);//12=Red, 16=Green, 27=Blue } |
void app_setup_pin(void) { /* Enable SWM clock before altering SWM */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON); Chip_GPIO_SetPinDIR(LPC_GPIO_PORT, 0, 4, false);//Push botton SW1. <== should use this or not? Chip_GPIO_SetPinDIR(LPC_GPIO_PORT, 0, 12, true);//led //12=Red, 16=Green, 27=Blue Chip_GPIO_SetPinDIR(LPC_GPIO_PORT, 0, 16, true);//led //12=Red, 16=Green, 27=Blue Chip_GPIO_SetPinDIR(LPC_GPIO_PORT, 0, 27, true);//led //12=Red, 16=Green, 27=Blue /* Connect SCT input 0 to SCT_IN0 */ Chip_SWM_DisableFixedPin(SWM_FIXED_ADC11);//PIO_04 disable Chip_SWM_MovablePinAssign(SWM_SCT_IN0_I, 4);//=SW1, Note its IN0 /* Connect SCT output 0,1,2 to LED pin PIO_12,16,27 respectively */ Chip_SWM_MovablePinAssign(SWM_SCT_OUT0_O, 12);//12=Red, 16=Green, 27=Blue Chip_SWM_MovablePinAssign(SWM_SCT_OUT1_O, 16);//12=Red, 16=Green, 27=Blue Chip_SWM_MovablePinAssign(SWM_SCT_OUT2_O, 27);//12=Red, 16=Green, 27=Blue /* Connect the INMUX Chip_INMUX_SetSCTInMux(LPC_INMUX, SCT_INMUX_0, SCT_INP_IN1 );// all other, SCT_INP_IN0, 2, 3 do not work!!! /* Example is using Input pin 0, INMUX_0, so why does the following not work: */ // Chip_INMUX_SetSCTInMux(LPC_INMUX, SCT_INMUX_0, SCT_INP_IN0 ); //BAD } |
typedef enum { SCT_INP_IN0, /*!< SCT0_IN0 selected by Pin Matrix */ /* FIXME: UM hints about changes */ SCT_INP_IN1, /*!< SCT0_IN1 selected by Pin Matrix */ SCT_INP_IN2, /*!< SCT0_IN2 selected by Pin Matrix */ SCT_INP_IN3, /*!< SCT0_IN3 selected by Pin Matrix */ SCT_INP_ADC_THCMP_IRQ, /*!< ADC Threshold compare IRQ */ SCT_INP_ACMP_O, /*!< Analog comparator output */ SCT_INP_ARM_TXEV, /*!< ARM TX Event */ SCT_INP_DEBUG_HALTED, /*!< Debug halted event */ } SCT_INP_T; |
Chip_SCT_SetControl(LPC_SCT, SCT_CTRL_CLRCTR_L | SCT_CTRL_HALT_L // H Counter: Clear and halt | SCT_CTRL_HALT_H | SCT_CTRL_CLRCTR_H // L Counter: Clear and halt | SCT_CTRL_PRE_H(SystemCoreClock/1000000-1) // Set the pre-scaler to 1Mhz | SCT_CTRL_PRE_L(SystemCoreClock/1000000-1)) ; // for both the L and H counters sct_fsm_init(); // Apply SCT configuration Chip_SCT_ClearControl(LPC_SCT, SCT_CTRL_HALT_L ); // Clear L Halt bit to start counter. |
<LPCXPRESSO INSTALL DIR>lpcxpresso_7.9.0_455/lpcxpresso/Examples/Legacy/NXP/LPC1000/LPC18xx/LPC1850A_Hitex.zip |
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); Chip_SYSCTL_PeriphReset(RESET_SCT); Chip_SCT_Init(LPC_SCT);/* enable the SCT clock and reset sct */ Chip_SCT_SetControl(LPC_SCT, SCT_CTRL_PRE_L(SystemCoreClock/1000000-1)); /* set prescaler, SCT clock = 1 MHz, clear counter */ sct_fsm_init(); Chip_SCT_SetControl(LPC_SCT, SCT_CTRL_PRE_L(SystemCoreClock/1000000-1)); /* set prescaler, SCT clock = 1 MHz, clear counter */ app_setup_pin(); |