NEW to LPC, please help ! - LPC 1769 basics - any help appreciated !

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

NEW to LPC, please help ! - LPC 1769 basics - any help appreciated !

1,206 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Jantje7600 on Tue Oct 07 12:14:23 MST 2014
Hello everyone,

I have a LPC1769 microcontroller and I would like to use it for my DC-AC inverter (using PWM).

I am a newbie, I have figured out how the blinky program works and a little bit more :)

On the internet I could not found any useful tutorial or book (I have read the user manual), many people on the internet say look at the examples. Well I did that but for me it is still not clear and the manual isn't a tutorial.

Along the way I have marked my questions with a number.


Please correct me if I'm wrong:
If I want to select GPIO Port 2.0 I use the following code:

        // Select P2.0 and use GPIO Port 2.0 function
  LPC_PINCON->PINSEL4 |= ( (0<<0) | (0<<1) );

1)  so LPC_PINCON is always used when a pin needs to be selected ?

        //According to manual: FIODIR = Fast GPIO Port Direction control register. This register individually controls the direction of each port pin.
// Set pin P2.0 as output
        LPC_GPIO2->FIODIR = (1<<0);
2) Okay, so when do I use FIODIR? Only when I have to declare the pin as an input or output?

// Set pin P2.0 high
LPC_GPIO2->FIOPIN |= (1<<0);

3) I have seen the following & = ~    so LPC_GPIO2->FIOPIN &= ~(1<<0); does this mean "disable" ? When is this used?


Now the real part comes. I want to use PWM (in combination with a driver IC) to drive my MOSFETS. First I want to know how I can use the PWM functionality of the LPC1769 to drive only one MOSFET.

To set the frequency of the PWM signal I need to use the clock frequency of the microcontroller I believe...

4) So do I have to use PCLKSEL0 and PCLKSEL1 ? If yes, how can I set them (please show the code :p, I think it is one line) ?
5) For pin select I use LPC_PINCON and for pheripheral clock I use LPC_SC is this correct?

In the manual it says:  "Peripheral clock: In the PCLKSEL0 register (Table 40), select PCLK_PWM1. "

6) Do I have to set it to 00 or 01 or 10 or 11? And why?

So assume I set it like this:
LPC_SC->PCLKSEL0 |= ((1 << 12) | (1 << 13));

Then
LPC_PINCON->PINSEL4 |= ( (1 << 0) | (0 << 1) ); //select PWM 1.1

and

LPC_PINCON->PINMODE4 |= ((0 << 0) |(1 << 1)); //Port 2 pin 0 control, this is somehow needed because of the pull-up/pull-down register which are both disabled

7) Have I missed something else? I just want to use a PWM to drive MOSFETS in order to drive my full bridge DC-AC inverter ( When I have finished this I will use a good Driver IC with bootstrapping for the inverter because the microcontroller cannot supply enough current to charge up the gate capacitance of the MOSFETS)

I know it is a lot but I would appreciate your help ! I really really searched a lot on the internet... Thanks
Labels (1)
0 Kudos
Reply
3 Replies

868 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jomonthomasnew on Mon Oct 19 06:23:27 MST 2015
You can find some good tutorials from the below link.
http://www.techmasterplus.com/tutorials.php

LPC1769 programming is not much different from other controllers like LPC14xx. You can follow that tutorials also.
0 Kudos
Reply

868 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Oct 08 02:35:56 MST 2014
You've chosen an excellent microcontroller.

1 + 2: Just set these when you initialize (that's when your program starts up, so normally it's once only).
3: To manually set pin 2.0 to high (eg. 3.3 volt on it), use
LPC_GPIO2->FIOPIN |= (1 << 0);

To manually set pin 2.0 to low (eg 0 volt on it), use
LPC_GPIO2->FIOPIN &= ~(1 << 0);


4+5+6: Use a library, such as LPCOpen. It does all this stuff for you, and you'll have less headache.

7: You should know, that you will always need to enable clock+power for each peripheral you are using.
By default, most of these are turned off. Eg. if you need to use a timer, you should turn it on yourself.
This is also done by the library, when you call init_*, but I want to mention it, in case you're stuck some day and have problems finding out why a peripheral doesn't want to start.

8: (well, had to make one up). Explore! Use small steps. When you are unsure about something, make a new project and test out your theories until you've found out how things needs to be done, then apply the result to your main project.

... Some details you might want to know if you're new ...

& means bitwise AND. All the specified bits are kept, the bits that are not specified will be cleared.
~ means bitwise NOT. It inverts all the bits in the remaining part of the expression.
| means bitwise OR. all the specified bits are set.

The line...
LPC_GPIO2->FIOPIN |= (1 << 0);

...could be written as ...
LPC_GPIO2->FIOPIN = LPC_GPIO2->FIOPIN | (1 << 0);

... it is exactly the same.
-So you could do the same thing with the other line...
LPC_GPIO2->FIOPIN = LPC_GPIO2->FIOPIN & ~(1 << 0);

... There is no difference, except from that it might be easier to understand for newcomers what is going on.
0 Kudos
Reply

868 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Tue Oct 07 21:37:14 MST 2014

Quote: Jantje7600
I know it is a lot but I would appreciate your help ! I really really searched a lot on the internet...



Start with a simple sample  :)

LPCOpen isn't including a PWM sample, so search this forum to find a sample from ex-sample writers  ;-)

See #7 of http://www.lpcware.com/content/forum/lpc1769-timer-question

0 Kudos
Reply