Hello,
There's an expansion board attached to the LPC2478 which contains a motor and a lightgate which can count the revolutions of the motor, connected to a counter (timer1).
My program is written to enable the user to select various motor speeds and receive feedback as to what the actual motor speed is, which is printed on the display.
The display contains various lines of text explaining the program and various speeds the user can select.
Essentially the problem I have is that for every line of 'lcd_putString' that is used, it multiplies the reading of the motor revolutions. There's 12 lines of lcd_putString which are used in the initialisation code of the program to print this text to the display and then never called upon again. If I comment these lines of text out, so that nothing other than the motor speed reading is display, the motor speed is displayed correctly on the display (tested using an oscilloscope).
To put it simply, if there is text printed to the display using lcd_putString, the counter reading is multiplied.
A lot of hours have gone into trying to sort this issue so any help is hugely appreciated.
When monitoring the signal from the lightgate which is counting the pulses, it doesn't appear to be carrying a lot of noise so I don't think it's reading extra pulses.
Does anyone have any further suggestions on this? Many other people have managed to achieve this so I can only assume there's an error in the code order or initialization.
I've now managed to narrow this down to the number of characters being rather than the lcd_putString function.
The simplified code below demonstrates the issue. The lcd_putString function prints 1 full line of characters, roughly, to the display. Removing some of the words from that, so it only covers about half a line, prints a more representative revolution count.
#include <lpc24xx.h> #include <textDisplay.h> #include <lcd_grph.h> int main(void) { int countval = 0; textInit(); lcd_init(); PINSEL2 |= (3<<6); PWM0PCR |= (1<<10); PWM0MR0 = 120000; PWM0MCR |= (1<<1); PWM0MR2 = 10000; PWM0TCR = 9; PINSEL3 |= (3<<6); T1TCR = 2; T1CTCR = 5; T1TCR = 1; lcd_putString(10,30, "This is a test to check if characters"); while(1) { countval = T1TC; textSetCursor(1,1); simplePrintf("%u", countval); } }