Lpcxpresso and LPC15XX

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

Lpcxpresso and LPC15XX

935 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ruchika123 on Thu Jan 07 22:19:12 MST 2016
Hello All,

I am using lpcxpresso board with LPC1549 and want to generate pwm pulse configuring SCT0 timer and want to toggle the output of the LED connected to P0_25 gpio on the board. But while building the program i encounter some errors. My code i as follows:

/*
===============================================================================
Name        : bldc_control.c
Author      : $(author)
Version     :
Copyright   : $(copyright)
Description : main definition
===============================================================================
*/

#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

#include <cr_section_macros.h>

// TODO: insert other include files here
#include "initializer.h"
//#include "LPC15xx.h"



// TODO: insert other definitions and declarations here







void SCT0_Init(void)
   {

LPC_SYSCON->SYSAHBCLKCTRL1 |= EN1_SCT0;                // enable the SCT0 clock
   LPC_SCT0->CONFIG            = (1 << 0) | (1 << 17);    // unified 32-bit timer, auto limit

   LPC_SCT0->MATCH[0].U        = SystemCoreClock/100 - 1; // match 0 @ 100 Hz = 10 msec
   LPC_SCT0->MATCHREL[0].U     = SystemCoreClock/100 - 1;

   LPC_SCT0->EVENT[0].STATE    = 0xFFFFFFFF;              // event 0 happens in all states
   LPC_SCT0->EVENT[0].CTRL     = (1 << 12);               // match 0 condition only

   LPC_SCT0->EVEN              = (1 << 0);                // event 0 generates an interrupt
   NVIC_EnableIRQ(SCT0_IRQn);                             // enable SC0 interrupt

   LPC_SCT0->CTRL_U &= ~(1 << 2);                         // start timer
   }



void SCT0_IRQHandler(void)
{
static uint8_t cnt = 0;

     if (++cnt > 20)                                // 20 * 10 msec = 200 msec
     {
         cnt = 0;
         LPC_GPIO->NOT[0] = (1 << 25);              // toggle pin P0_25
     }
     LPC_SCT0->EVFLAG = 0x00000001;                 // clear event 0 flag

}





int main(void)
{
LPC_SYSCON->SYSAHBCLKCTRL0 |= EN0_GPIO0;       // enable clock to GPIO port 0
LPC_GPIO->DIR[0]           |= (1 << 25);       // configure P0_25 (red LED) as output

SCT0_Init();                                   // Initialize SCT





#if defined (__USE_LPCOPEN)
    // Read clock settings and update SystemCoreClock variable
    SystemCoreClockUpdate();
#if !defined(NO_BOARD_LIB)
    // Set up and initialize all required blocks and
    // functions related to the board hardware
    Board_Init();
    // Set the LED to the state of "On"
    Board_LED_Set(0, true);
#endif
#endif

    // TODO: insert code here

    // Force the counter to be placed into memory
   // volatile static int i = 0 ;
    // Enter an infinite loop, just incrementing a counter
   InputMux_Init();
   IOCON_Init();
   SwitchMatrix_Init();
    // GPIO Initialization.
    //SCT Initialization.


    while(1)
    {
      }

}

I get the errors when i try to enable the clock to SCT0 and GPIO port 0. The errors are:

../src/bldc_control.c:38:13: error: 'LPC_SYSCTL_T' has no member named 'SYSAHBCLKCTRL1'
../src/bldc_control.c:38:33: error: 'EN1_SCT0' undeclared (first use in this function)
../src/bldc_control.c:74:12: error: 'LPC_SYSCTL_T' has no member named 'SYSAHBCLKCTRL0'
../src/bldc_control.c:74:32: error: 'EN0_GPIO0' undeclared (first use in this function)
make: *** [src/bldc_control.o] Error 1

I have intialized the pwm pins as well as the adc pins using lpc intializer for my application. I just wanted to test the above example to see if everything is working. First i want to toggle the led using pwm amd then observe the pwm pattern on the scope. So, i needed some help regarding this.


Thanks,
Ruchika
Labels (1)
0 Kudos
Reply
2 Replies

806 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Mon Jan 11 10:20:00 MST 2016
Hi Ruchika,
SYSAHBCLKCTRL[2]  is an array for two registers declared under structure LPC_SYSCTL_T. Separate registers SYSAHBCLKCTRL0 and SYSAHBCLKCTRL1 are not defined.  You can use Chip_Clock_EnablePeriphClock(...) to enable clock to SCT.
0 Kudos
Reply

806 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Jan 08 01:52:55 MST 2016

Quote: ruchika123
The errors are:
../src/bldc_control.c:38:13: error: 'LPC_SYSCTL_T' has no member named 'SYSAHBCLKCTRL1'
../src/bldc_control.c:38:33: error: 'EN1_SCT0' undeclared (first use in this function)
../src/bldc_control.c:74:12: error: 'LPC_SYSCTL_T' has no member named 'SYSAHBCLKCTRL0'
../src/bldc_control.c:74:32: error: 'EN0_GPIO0' undeclared (first use in this function)
make: *** [src/bldc_control.o] Error 1



And what's not clear there  :quest:



0 Kudos
Reply