Lpcxpresso 1769

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

Lpcxpresso 1769

3,323 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Thu Jun 16 05:06:16 MST 2011
Hi,

I started to implement pwm on 1769.
I can debug code but ,its not working.I want to drive DC motor...ıs anybody implement this task before...
What are the single edge or anorher types defined in user manual...
0 Kudos
Reply
13 Replies

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Jun 17 18:22:57 MST 2011
User manual UM10360 PWM Description:


Quote:

Two match registers can be used to provide a single edge controlled PWM output. One match register (PWMMR0) controls the PWM cycle rate, by resetting the count upon match. The other match register controls the PWM edge position. Additional single edge controlled PWM outputs require only one match register each, since the repetition rate is the same for all PWM outputs. Multiple single edge controlled PWM outputs will all have a rising edge at the beginning of each PWM cycle, when an PWMMR0 match occurs.


uint32_t PWM_Init( uint32_t ChannelNum, uint32_t cycle )
{
  if ( ChannelNum == 1 )
  {
 match_counter1 = 0;
 LPC_PINCON->PINSEL4 = 0x00001555; /* set GPIOs for all PWM pins on PWM */
 LPC_PWM1->TCR = TCR_RESET; /* Counter Reset */ 
 LPC_PWM1->PR = 0x00;  /* count frequency:Fpclk */
 LPC_PWM1->MCR = PWMMR0I; /* interrupt on PWMMR0, reset on PWMMR0, reset 
        TC if PWM matches */    
 LPC_PWM1->MR0 = cycle;  /* set PWM cycle */
 LPC_PWM1->MR1 = cycle * 5/6;
 LPC_PWM1->MR2 = cycle * 2/3;
 LPC_PWM1->MR3 = cycle * 1/2;
 LPC_PWM1->MR4 = cycle * 1/3;
 LPC_PWM1->MR5 = cycle * 1/6;
 LPC_PWM1->MR6 = 0; 
 /* all PWM latch enabled */
 LPC_PWM1->LER = LER0_EN | LER1_EN | LER2_EN | LER3_EN | LER4_EN | LER5_EN | LER6_EN;
  }
  else
  {
 return ( FALSE );  /* Unknown channel number */
  }
  NVIC_EnableIRQ(PWM1_IRQn);
  return (TRUE);
}

So what's not clear there?
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Fri Jun 17 17:51:33 MST 2011
I meant pwm channel one :)
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Jun 17 11:15:48 MST 2011

Quote:

...PWM1...

My board has no PWM1 pin :confused:
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Fri Jun 17 10:42:19 MST 2011
That ı am succeed and its working with 0.5 hz,by the way when I check that PWM1 with led ,its not blinking :s so ı have again problem ...:S why its not working?
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Jun 17 08:14:56 MST 2011
If you run the original example:

1. clock = 72MHz

2. pwm clock = clock /4 = 18MHz

3. divider = 1200

4. result: 72E6/4/1200=15kHz

With 3.6E6 you will get 0.5 Hz :)
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Fri Jun 17 08:02:44 MST 2011
Zero I need your help...I want to implement it on led...so
that cycle is defined 1200...
I can not calculate times...I wanna have 2 second cycle...
when cycle is 1200 my period will be o how many second ? ....
LPC_PWM1->MR0 = cycle;
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Thu Jun 16 10:51:50 MST 2011
Brother its ok,found it and try with version 2,zero thank you ....we wanna see you in Turkey...
You resolve my problem again smilar my I2C problem...I will never forget your help...
I am trying to write source in Turkish for make lpc pervasive in Türkiye.
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 16 10:46:16 MST 2011
Original project is using CMSISv2_LPC17xx. Are you still using the original project?
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Thu Jun 16 10:34:40 MST 2011
Standart code can be seen below.So when I remove  SystemClockUpdate();
is it working correctly?

#include <cr_section_macros.h>
#include <NXP/crp.h>

// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#include "lpc17xx.h"
#include "type.h"
#include "pwm.h"

#define CHANNEL_NUM            1

extern volatile uint32_t match_counter1;

/******************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{       
  uint32_t cycle = PWM_CYCLE, offset = 0;

  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate();

  if ( PWM_Init( CHANNEL_NUM, 0 ) != TRUE )
  {
    while( 1 );            /* fatal error */
  }

  PWM_Set( CHANNEL_NUM, cycle, offset );
  PWM_Start( CHANNEL_NUM );

  while ( 1 )
  {
    if ( match_counter1 != 0 )
    {
      match_counter1 = 0;
      PWM_Set( CHANNEL_NUM, cycle, offset );
    }
  }
}
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 16 10:14:34 MST 2011
This sample is using another version of CMSIS. So if you copy just pwm.c and pwm.h in your own src folder, there can be a few errors.

SystemClockUpdate() is not needed in a standard LPCXpresso / CMSIS project

#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

#include "pwm.h"

#define CHANNEL_NUM            1

extern volatile uint32_t match_counter1;


// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

// TODO: insert other include files here

// TODO: insert other definitions and declarations here

int main(void)
{
// TODO: insert code here
  uint32_t cycle = PWM_CYCLE, offset = 0;
  if (PWM_Init( CHANNEL_NUM, 0 ) != 1)
  {
    while( 1 );            /* fatal error */
  }
  PWM_Set(CHANNEL_NUM, cycle, offset );
  PWM_Start( CHANNEL_NUM );
  while (1)
  {
  }
}
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Thu Jun 16 10:07:39 MST 2011
SystemClockUpdate(); gives me error...relevant to Version 2 :s
I am thorougly confused zero...
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Thu Jun 16 06:39:16 MST 2011
Zero you are the best of bests...
0 Kudos
Reply

3,255 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 16 05:32:27 MST 2011

Quote:

...I can debug code but ,its not working...

That's a little bit general :)

What code (PWM sample ?) and what isn't working?

Note: PWM Example in lpcxpresso_3.6.3_317\Examples\NXP\LPC1000\LPC17xx\NXP_LPCXpresso1769_MCB1700_2011-02-11.zip creates a wonderful 15 kHz signal
0 Kudos
Reply