Set / Clear IO bit in LPCOpen (very-very beginner)

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Bela on Wed Nov 05 08:02:50 MST 2014

I'm new to Cortex M3, also to LPCXpresso, and to LPCOpen and even to C language. But I do have a motivation to learn it all :-)

I use LPCXpresso 7.3.0 on Ubuntu 14.04.
An LPCXpresso 1768 board is connected.
I can open an existing example-project, in my case it is a blinky example, it compiles and can be downloaded to the board. Since it just blinks, there's nothing to do with.
It took me a while, while I could recognize that CMSIS, mbed and LPCOpen are different things and shouldn't be mixed up :-) I decided to try to use LPCOpen.

My next step is to write my own code for something similar.
There's an LED on P0.22, I want to control it's brightness up and down slowly, employing PWM principle.
To do this, I could use Timer0 and one (or two) of the match registers. They could procuce an internal PWM and I could control the P0.22 in software, because this pin cannot be controlled directly by the built-in PWM hardware. The PWM rate would be changed by SysTick IT, one step in every 10 msec by incrementing / decrementing the value in Timer0/match0 register. Match0 could provide the duty cycle, Match1 the PWM period and it also resets Timer0. That's my idea.

Here are the problems coming in.

1.:   There's only one IT vector for Timer0. How can my code detect if this IT is due to one of the match registers? Both should have it's IT enabled.

2.:   I couldn't find out how could I write a value into Timer0/Match0 and Match1 register?
       LPCXpresso gives proposals to some registers, for example like this: LPC_SYSCTL->PCONP Here PCONP comes up automatically as I enter LPC_SYSCTL-> .
       But if I try LPC_TIMER0-> here just MR is valid. In the user manual I see 4 match registers for each of the timers, not only one. I don't understand, how could I access one out of the 4.

3.:  How could I set and/or clear the P0.22 bit? When I try LPC_GPIO_T-> no proposal comes, and whatever I try to finish this instruction, it doesn't compile, saying:
../src/Proba03.c:101:12: error: expected identifier or '(' before '->' token
  LPC_GPIO_T->CLR0 = (1<<22);    // LED1 output low (On)
Similarly, I couldn't acces the IO control bits, because LPC_IOCON_T->  doesn't compile and doesn't give proposals.

4.:  Is there a verbosely written documentation of LPCOpen? I do have this HTML docu: http://www.lpcware.com/system/files/lpcopen_2_10_docs_17xx_40xx.zip but it is not written for beginners.

It is so inconvenient sitting in the darkness, could someone help me, please?