Uploading firmware to LPC11c14, What can I set for converting high level output to low level as initial condition.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Uploading firmware to LPC11c14, What can I set for converting high level output to low level as initial condition.

586 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ctchen on Fri Aug 21 20:15:59 MST 2015
Dear everyone.

When I upload the firmware to LPC11C14, Digital output ports are always high level.

So, application test is inconvenient.

What can I do something in order to solve this problem that is converting high level to low level as initial condition ?

My development environment :
(1) LPC11C14
(2) IAR EWARM 5.5
(3) Segger J-LINK
0 Kudos
Reply
3 Replies

526 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Aug 24 23:01:29 MST 2015
I'm not sure what you are trying to do in detail  :~

Default pin status is input / high, so if that's a problem during downloading / reset you have to add a pulldown resistor or inverter...
0 Kudos
Reply

526 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ctchen on Mon Aug 24 18:38:12 MST 2015
Despite of your kine, I'm so sorry for late reply because of my other work.

My simplified source code is bellow

void GpioInit(void)
{
  // Set to inputs
  GPIO0DIR = \
  GPIO1DIR = \
  GPIO2DIR = \
  GPIO3DIR = 0;
 
  // Reset all GPIO pins to default primary function
  IOCON_PIO2_6 = \
  IOCON_PIO2_0 = \
  IOCON_RESET_PIO0_0 = \
  //IOCON_PIO0_1 = 0x12 ;// Enable CT32B0_MAT2, Pull-Up
  IOCON_PIO1_8 = \
  IOCON_PIO0_2 = 0x10 ;   // Low Side Enable for Sol-A
  IOCON_PIO2_7 = \
  IOCON_PIO2_8 = \
  IOCON_PIO2_1 = \
  IOCON_PIO0_3 = 0x10 ;   // Low Side Enable for Sol-B
  IOCON_PIO1_9 = \
  IOCON_PIO2_4 = \
  IOCON_PIO2_5 = \
  IOCON_PIO0_6 = \
  IOCON_PIO0_7 = \
  IOCON_PIO2_9 = \
  IOCON_PIO2_10 = \
  IOCON_PIO2_2 = \
  IOCON_PIO0_8 = \
  IOCON_SWCLK_PIO0_10 = \
  IOCON_PIO2_11 = \
  IOCON_PIO3_0 = \
  IOCON_PIO3_1 = \
  IOCON_PIO2_3 = \
  IOCON_PIO3_2 = \
  IOCON_PIO1_5 = \
  IOCON_PIO3_3 = 0x50 ;
  IOCON_R_PIO1_0 = \
  IOCON_PIO0_4 = \
  IOCON_PIO0_5 = 0x00;
}


void InitClock(Int32U clock, Int32U ahbdiv)
{
    SYSOSCCLTRL = (MAIN_OSC_FREQ>(20MHZ))?(0x2):(0x0);        // Sys Ocilator Enable, 12MHz
    PDRUNCFG_bit.SYSOSC_PD = 0;                               // Power Up SYS Oscilator
    PDRUNCFG_bit.IRC_PD = 0;                                  // Enable Internal RC oscilator
    /*Select internal RC oscilator for
    Sys clock source*/
    MAINCLKUEN = 0;
    MAINCLKSEL = 0;
    MAINCLKUEN = 1;
    /*Configure SYS PLL*/
    /*Power Down SYS PLL*/
    PDRUNCFG_bit.SYSPLL_PD = 1;
    /*Select Sys Oscilator for
    SYS PLL source*/
    SYSPLLCLKUEN = 0;
    SYSPLLCLKSEL = 1;
    SYSPLLCLKUEN = 1;
    /*Calc M*/
    Int32U m = clock/MAIN_OSC_FREQ - 1 ;
   
    assert(m<32);
    /*Configure PLL frequency*/
    SYSPLLCTRL =  (m)    /*MSEL*/
             |  (1<<5) /*PSEL = 1*/ // original value 0<<5
             |  (0<<7) /*DIRECT = 0*/
             |  (0<<8); /*BYPASS=0*/
   
    /*Power Up PLL*/
    PDRUNCFG_bit.SYSPLL_PD = 0;
    /*Set Sys AHB Clock devider*/
    SYSAHBCLKDIV_bit.DIV = ahbdiv;
    /*Wain until PLL locks*/
    while(!(SYSPLLSTAT_bit.LOCK));
    /*Select Sys PLL Output for
    Sys clock source*/
    MAINCLKUEN = 0;
    MAINCLKSEL = 3;
    MAINCLKUEN = 1;
}


/* PWM Generation using TMR32B0 & TMR32B1 */
void _PWM32BIT_INIT()
{
    IOCON_PIO0_1 = 0x0 ;
    IOCON_PIO0_1 = 0x12 ;// Enable CT32B0_MAT2, Pull-Up
    IOCON_PIO0_2 = 0x10 ;   // Low Side Enable for Sol-A (Pull-Up)

    IOCON_R_PIO1_1 = 0x0 ;
    IOCON_R_PIO1_1 = 0x13 ;  // Enable CT32B0_MAT3, Pull-up
    IOCON_PIO0_3 = 0x10 ;   // Low Side Enable for Sol-B (Pull-Up)

    GPIO0DIR = 1<<2 | 1<<3 ;    // Define as output
    GPIO0DATA = 1<<2 | 1<<3 ;   // Enable Output PIO0_2 & PIO0_3
   
    SYSAHBCLKCTRL_bit.CT32B0 = 1 ;        //  Enable TIMER 0 clocks
    SYSAHBCLKCTRL_bit.CT32B1 = 1 ;        //  Enable TIMER 1 clocks

    TMR32B0MR3 = Max_Duty ;  //period, 9600 : 5kHz, 4800000 : 10Hz
    TMR32B1MR3 = Max_Duty ;  //period, 9600 : 5kHz, 4800000 : 10Hz
   
    // Match Control Register for MR2 & MR3
    TMR32B0MCR_bit.MR3I = 0;   // Enable Interrupt on MR3
    TMR32B0MCR_bit.MR3R = 1;   // Enable reset on MR3
    TMR32B0MCR_bit.MR3S = 0;   // Disable stop on MR3
   
    TMR32B1MCR_bit.MR3I = 0;   // Enable Interrupt on MR2
    TMR32B1MCR_bit.MR3R = 1;   // Enable reset on MR2
    TMR32B1MCR_bit.MR3S = 0;   // Disable stop on MR2
   
    TMR32B0TC = 0 ;
    TMR32B1TC = 0 ;
   
    // PWM Control Register
    TMR32B0PWMC_bit.PWM2ENA = 1 ;     // Enable PWM ch2
    TMR32B1PWMC_bit.PWM0ENA = 1 ;     // Enable PWM ch0
   
    // Timer Control Register
    TMR32B0TCR_bit.CE = 1 ;
    TMR32B1TCR_bit.CE = 1 ;
}

inline void _PWM_SIG_INITIALIZATION(Int32U duty_A, Int32U duty_B)
{
  unsigned int dumy_cnt = 0 ;
  for(dumy_cnt = 0; dumy_cnt < 5000; dumy_cnt++)
  {
    TMR32B0MR2 = Max_Duty - duty_A ;
    TMR32B1MR0 = Max_Duty - duty_B ;
  }
}

int main(void)
{
    SYSAHBCLKCTRL_bit.GPIO = 1 ;     // Enable GPIO Clock
    SYSAHBCLKCTRL_bit.IOCON = 1 ;     // Enable IOCON Clock
   
    InitClock(48MHZ, 1) ;            // Init clock, 132MHz / 3 = 48MHz
    GpioInit();                       // Set all pins as input ports except some part
    _PWM32BIT_INIT() ;              // Meaning of function input, Enable Timer. Ticks 10 times per second
   
    while(1)
    {
          _PWM_SIG_INITIALIZATION(5000, 5000) ;
    }
}

0 Kudos
Reply

526 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Badman on Sat Aug 22 03:07:13 MST 2015
Show your code.
0 Kudos
Reply