7 years, 10 months ago.

Why when I use the LCD_F429ZI library does it change the operation of my entire program?

Within my project, I have a 7 seg display. When the system starts up display = 0, My entire code works 100%. But as soon as i start implementing the tft lcd section, it acts weird. I am using State machines. I tried using pins that are not connected to the LCD, but this didnt work. Please help

here is my code:

  1. include "mbed.h" ARMmbed libraries will be used
  2. include "SWO.h"
  3. include "LCD_DISCO_F429ZI.h"

PwmOut motorpwd(PB_4); DigitalOut motorfwd(PA_0); DigitalOut motorrev(PA_5); DigitalIn SensorEntrance(PD_7); DigitalIn SensorExit(PD_6); BusOut Display(PC_4, PB_7, PA_8, PA_7); DigitalIn openLimit (PE_7); DigitalIn closeLimit (PE_9); DigitalOut AlarmLED (PG_14); DigitalOut SystemGOOD (PG_13); SWO_Channel SWO;

Serial bt(PC_10, PC_11); create a Serial object to connect to the HC06 Bluetooth module tx , rx

LCD_DISCO_F429ZI lcd;

char btmsg; character variable to store incoming bt message int new_btmsg = 0; flag to indicate if a new .message was received int DisplayValue ;

this interrupt routine is called when a new character is received void btinterrupt() { if(new_btmsg == 0) make sure previous message was handled first before fetching next instruction message { btmsg = bt.getc(); read the incoming character new_btmsg = 1; set the flag to indicate that there is a new message } }

void ServiceStateMachine(void); Function to service the state machine

Timer my_timer; Timer object for creating the time delay

enum state_type{GATE_CLOSING, GATE_OPENING, GATE_OPENED, GATE_CLOSED, PFULL};

state_type cur_state = GATE_CLOSING;

/* ***** Main Program Code ***** */

int main() { System initialization motorpwd.period(0.00005); Set DC motor PWM period to 50mS = 50Hz motorpwd = 0.5; Set DC motor duty cycle to 50% - default speed motorfwd = 0; motorrev = 0; my_timer.start(); Start the MBED timer Display = DisplayValue; Display = 0; Dislplay 0 on 9 segment display SystemGOOD = 1; AlarmLED = 0; BSP_LCD_SetFont(&Font20);

lcd.Clear(LCD_COLOR_WHITE); lcd.SetBackColor(LCD_COLOR_WHITE); lcd.SetTextColor(LCD_COLOR_BLUE); lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"AUTOMATED ACCESS", CENTER_MODE); lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"SYSTEM", CENTER_MODE);

wait(0.2); bt.attach(&btinterrupt); if a new character arrives, call the interrupt service routine

while(1) Permanent loop { ServiceStateMachine(); Execute the state machine code } }

void ServiceStateMachine(void) { switch(cur_state) Read current state { case GATE_CLOSING: GATE_CLOSING STATE { SystemGOOD = 1; motorfwd = 1; Gate motor running forward motorrev = 0; my_timer.reset(); Reset the delay timer SWO.printf("GATE IS CLOSING \n");

if(closeLimit == 1) Is gate is closed position? cur_state = GATE_CLOSED; Yes - set GATE_CLOSED state

} break;

case GATE_OPENING: GATE_OPENING STATE { SystemGOOD = 1; motorfwd = 0; Gate motor running reverse motorrev = 1; my_timer.reset(); Reset the delay timer SWO.printf("GATE IS OPENING \n");

if(openLimit == 1) { Is gate is opened position? cur_state = GATE_OPENED; Yes - set GATE_OPEED state Display = Display + 1;}

} break; case GATE_OPENED: { GATE_OPENED STATE SystemGOOD = 1; motorfwd = 0; Gate motor off motorrev = 0; SWO.printf("GATE IS OPENED \n");

if(my_timer >= 7) Received a valid wireless remote signal? cur_state = GATE_CLOSING; Yes - set GATE_CLOSING state } break;

case GATE_CLOSED: { GATE_CLOSED STATE SystemGOOD = 1; DisplayValue = Display; SWO.printf("GATE IS CLOSED \n\n"); SWO.printf("VEHICLES IN = %d \n",DisplayValue); motorfwd = 0; Gate motor off motorrev = 0;

if(SensorEntrance == 1 || SensorExit == 1) Reveived a valid wireless remote signal? cur_state = GATE_OPENING; Yes - set GATE_OPENING state

if (Display == 9) cur_state = PFULL;

if(Display > 0 && SensorExit == 1) Display = Display - 1; } break;

case PFULL: { motorfwd = 0; motorrev = 0; AlarmLED = 1; SystemGOOD = 0; SWO.printf("PARKING IS FULL \n");

if(SensorExit == 1) cur_state = GATE_OPENING;

} break; }

if(new_btmsg) { check if there is a new message if(btmsg=='a') message for ORANGE LED (LD3) ON cur_state = GATE_OPENING;

else if(btmsg=='c') message for ORANGE LED (LD3) OFF cur_state = GATE_CLOSING;

else{ bt.printf("Incorrect command\n"); Reply incorrect command SWO.printf("Incorrect Command Entered \n");}

new_btmsg=0; clear message flag }

}

It's hard to read the code without formatting. Please puts all your code between <<code>> code here <</code>>. For better alignment and easy to read.

posted by Fred Li 13 Jan 2017

Good day, I have managed to sort the problem out. Everything is working now. Thank you

posted by Chadd Contell 14 Jan 2017
Be the first to answer this question.