RTC Display on LED Board

27 Jun 2012

Hi, I'm trying to program an RTC time display on a LED board, model M500N-7X80RG2. I managed to get the time and everything right, including the input from PC, but the board refreshes every second, flashing and making this beeping noise.

My code is as follows:

#include "mbed.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <math.h>
#define MESSAGE_BUFFER_SIZE 1024
#include "lib_crc.h"

Serial pc(USBTX,USBRX);
Serial Computer(USBTX, USBRX);
Serial LEDScreen(p9,p10);
DigitalOut ho(p26);

char line = '\n';
char c;
char sav[40];
char tstr[32];
struct tm t;
time_t seconds;

void LEDSerialstart() {  //Starting code for LED Screen
    LEDScreen.putc(0x00);
    LEDScreen.putc(0xff);
    LEDScreen.putc(0xff);
    LEDScreen.putc(0x00);
    LEDScreen.putc(0x0b);
    LEDScreen.putc(0x00);
    LEDScreen.putc(0x01);
    LEDScreen.putc(0xff);
    LEDScreen.putc(0x01);
    LEDScreen.putc(0x01);
    LEDScreen.putc(0x03);
    LEDScreen.putc(0xef);
    LEDScreen.putc(0xb0);
    LEDScreen.putc(0xef);
    LEDScreen.putc(0xa2);
}

void New_Screen() {   //New Frame for LED screeen
    LEDScreen.putc(0xef);
    LEDScreen.putc(0xb1);
    LEDScreen.putc(0xef);
    LEDScreen.putc(0xa0);
    LEDScreen.putc(0xff);
    LEDScreen.putc(0xef);
    LEDScreen.putc(0xb0);
    LEDScreen.putc(0xef);
    LEDScreen.putc(0xa2);
}

void LEDSerialend() {  //Ending code for LED screen
    LEDScreen.putc(0xff);
    LEDScreen.putc(0xff);
    LEDScreen.putc(0x00);
}

void Display() {  //Getting Data and putting on LED Screen
    LEDScreen.baud(2400);
    Computer.baud(2400);
    LEDSerialstart();
    time_t seconds = time(NULL);
    strftime(tstr, 32,"%H:%M:%S", localtime(&seconds));
    LEDScreen.printf("%s", tstr);
    wait(0.95);
    LEDSerialend();
    Computer.baud(9600);
}

void input() {
    memset(sav, 0, 40);
    do {
        c = pc.getc();
        pc.putc (c);
        strcat(sav, &c);
    } while (c != ' ');
}

void TimeSet() {

    pc.printf("SET TIME\n\r");
    pc.printf("--------\n\n\r");

    do {
        pc.printf("Please input local time:\n\r");
        pc.printf("YYYY MM DD HH MM SS\n\r");

        input();
        t.tm_year = atoi(sav);
        input();
        t.tm_mon  = atoi(sav);
        input();
        t.tm_mday = atoi(sav);
        input();
        t.tm_hour = atoi(sav);
        input();
        t.tm_min  = atoi(sav);
        input();
        t.tm_sec  = atoi(sav);

        pc.printf("\n\n\r");
        pc.printf("Is the time correct? [Y/N]\n\n\r");
        c=pc.getc();
    } while (c != 'y' && c != 'Y');

    t.tm_year = t.tm_year - 1900;
    t.tm_mon = t.tm_mon - 1;

    set_time(mktime(&t));
}

int main () {
    TimeSet();
    while (1) {
        Display();
    }
}

Any help would be greatly appreciated!!

03 Jul 2012

Hi, I just found this post as I'm looking up the mbed RTC. Have you solved your issues?

I haven't found any useful data on the LED display protocol, but your issues seem to indicate a comms failure or a power supply failure, hence the alarm sound.

The internet seems to have manuals for the display using a PC program, have you got this and can you test your display with it?

03 Jul 2012

Chai Su Tian wrote:

Serial pc(USBTX,USBRX);
Serial Computer(USBTX, USBRX);

Any help would be greatly appreciated!!

Is it safe to use the same pins like this? Is there a reason you're creating two serial objects instead of one?

04 Jul 2012