Welcome, Guest
Username Password: Remember me

Beginners problem with GPIO and Timer
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Beginners problem with GPIO and Timer

Beginners problem with GPIO and Timer 29 Sep 2012 10:53 #313

  • frankw
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
I just received my Simplecortex board and now I'm starting to learn using the processor.

I've compiled the Interrupttimer_CoIDE example program from the BRCElectronics-simplecortex-repo-f33d1c17bf59.

I've changed the I/O setting according to the circuit diagramm, so that it matches the actual hardware.

GPIOSetDir(1, 18, 1);
GPIOSetDir(1, 19, 1);
GPIOSetDir(1, 24, 1);
GPIOSetDir(1, 25, 1);

When I run the programm, LED9 (I/O 1.25) is allways blinking with the same speed.
Regardless what time is set for timer3.
Even when I hit a breakpoint in the debugger, LED9 is still blinking.

It appears as if this I/O is somehow not controlled by the software, but by some other processor function.

Any Ideas what I could have done wrong ?

Thank's for your assistance.

Frank


p.s.

Here's the full source :

#include "LPC17xx.h"
#include "lpc_types.h"
#include "GPIO.h"
#include "timer.h"

uint32_t toggle = 0;
uint32_t toggle1 = 0;
uint32_t toggle2 = 0;
uint32_t toggle3 = 0;

int main(void)
{
init_timer(0, 15000000);
init_timer(1, 30000000);
init_timer(2, 60000000);
init_timer(3, 120000000);
enable_timer(0);
enable_timer(1);
enable_timer(2);
enable_timer(3);
GPIOSetDir(1, 18, 1);
GPIOSetDir(1, 19, 1);
GPIOSetDir(1, 24, 1);
GPIOSetDir(1, 25, 1);
while(1)
{
}
}

void TIMER0_IRQHandler (void)
{
TIMER0_interrupt();
toggle = ~toggle;
GPIOSetValue(1, 18, toggle);
}

void TIMER1_IRQHandler (void)
{
TIMER1_interrupt();
toggle1 = ~toggle1;
GPIOSetValue(1, 19, toggle1);
}

void TIMER2_IRQHandler (void)
{
TIMER2_interrupt();
toggle2 = ~toggle2;
GPIOSetValue(1, 24, toggle2);
}

void TIMER3_IRQHandler (void)
{
TIMER3_interrupt();
toggle3 = ~toggle3;
GPIOSetValue(1, 25, toggle3);
}
Last Edit: 29 Sep 2012 11:18 by frankw. Reason: Typo

Re: Beginners proboem with GPIO and TImer 29 Sep 2012 11:19 #314

  • rik
  • OFFLINE
  • Administrator
  • Posts: 105
Hello

Could you open timer.h and change this line:
#define TIMER_MATCH 1
To this
#define TIMER_MATCH 0
And check if that solves the problem?

Rik

Re: Beginners proboem with GPIO and TImer 29 Sep 2012 11:33 #315

  • frankw
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Hi again,

i've changed TIMER_MATCH.
Now LED9 and LED8 appear to function like they should.
But - for some reason, LED7 and LED6 don't blink anymore.
I've checked in the debugger - the interrupt routines for LED6/7 still
are called - but the GPIOSetValue appears not to work anymore.
... strange ( at least to me as a LPC1769 beginner )

Re: Beginners proboem with GPIO and TImer 29 Sep 2012 11:55 #316

  • cornelis
  • OFFLINE
  • Administrator
  • Posts: 125
Hey,

I modified the timer library and the timer interrupt example. The changes are uploaded to the repository. Note that the defines TIMER_MATCH and TIMER_CAPTURE must be zero (default).
The problem with the interrupt handler is also solved.

Regards, Cornelis

Re: Beginners proboem with GPIO and TImer 29 Sep 2012 17:22 #317

  • frankw
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Turbo fast response. I'm impressed.
Thank's
Frank

Re: Beginners problem with GPIO and Timer 29 Sep 2012 17:43 #318

  • frankw
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
.... just tried it.
Now it works.

Thank you.
  • Page:
  • 1
Time to create page: 0.18 seconds
Copyright 2011. Joomla 1.7 templates - Joomla template maker. The Simplecortex is developed by BRC-Electronics