11 years, 11 months ago.

xbee does not work after the init_vga() in vga640*480graphic libraray?

i am trying to get data from xbee and then display it on vga. but xbee does not work after the init_vga command in vga640*480graphic buitin libraray?

/*
 * 640x480 60Hz fullgraphic monochrome VGA Driver demo program
 *
 * Copyright (C) 2011 by Ivo van Poorten <ivop(at)euronet.nl>
 * and Gert van der Knokke <gertk(at)xs4all.nl>
 * This file is licensed under the terms of the GNU Lesser
 * General Public License, version 3.
 *
 * Inspired by Simon's (not Ford) Cookbook entry and Cliff Biffle's
 * assembly code.
 */
 
#include "mbed.h"
#include "vga640x480g.h"
Serial xbee1(p9, p10);
DigitalOut rst1(p11);

// visual feedback
DigitalOut myled(LED1);
DigitalOut myled1(LED2);
void vga(void)
{
myled1=1;
init_vga();
wait(0.001);

    int s,t;

    // serial port on at 115200 baud
    //linktopc.baud(115200);
    setbuf(stdout, NULL); // no buffering for this filehandle
    
    
    // clear the screen
    vga_cls();
    
    // draw some circles
    for (t=10; t<200; t+=5)
    {
    vga_circle(20+t,399-t,t,WHITE);
    wait(0.04);
    }
    myled1=0;

    // draw some boxes
    for (t=10; t<100; t+=5)
    vga_box(400+t,100+t,400+t*2,100+t*2,WHITE);
  
    // circumfence the screen
    vga_box(0,0,639,479,WHITE);
    
    // show the complete character set
    for (s=0; s<4; s++) {
        for (t=0; t<64; t++) {
            vga_putchar(20+t*8,20+16*s,t+s*64,WHITE);
        }
    }

    // put a string on screen
    vga_putstring(400,370,"Hello World!",WHITE);
    myled1=0;

    // draw some lines
    vga_line(400,390,500,390,WHITE);
    vga_line(500,475,600,375,WHITE);

    // draw a filled box
    vga_filledbox(450,330,550,360,1);

    // draw some more boxes
    for (t=10; t<320; t+=5)
    vga_box(100+t,440-t/16,110+t,440+t/16,WHITE);
    myled1=1;
}

// visual feedback
//DigitalOut myled(LED1);

// define serial port for debug
Serial linktopc(USBTX,USBRX);

int main() {
vga();


wait(10);
rst1 = 0;   //Set reset pin to 0
   myled = 0;
   myled1= 1;
  wait_ms(1);
   rst1 = 1;   //Set reset pin to 1
   wait_ms(1);
    unsigned char buff[2000];
    while(1)
//for (int i=0; i<10000; i++)

{// j++;
        if(xbee1.readable())
        {
        myled1=1;
        wait(0.004);
        myled1=0;
        wait(0.004);
        }
        }
    // init the VGA subsystem (always do this first!)
    
    
    
    // all done
    while (1){
         wait(1);
       myled=!myled;
    }
 }

1 Answer

11 years, 11 months ago.

Could be many things, you can for example find it out yourself by starting to disable stuff from init_vga, until your xbee works again, that way you can narrow down what is exactly causing it.

One issue is that init_vga sets the clock to 100MHz, and standard is 96MHz. That is just the edge of if it is too much difference or not, so that can be the issue. So try setting the baudrate of the xbee serial object to 9600*96/100 = 9216.

only one of them work at a time?

posted by sanwal muneer 16 Dec 2012

I have no idea what your question is.

posted by Erik - 16 Dec 2012

i want to read data from xbee and display it over vga. vga itself and xbee receiving programs works well stand alone but when i merge them then xbee doest not work as the init_vga upsets the uart.

posted by Noman Malik 16 Dec 2012

Well I answered that issue, at least worth a try to adapt the baudrate.

posted by Erik - 16 Dec 2012

i have cheked it . so whenever i put some delay before init_vga for configuring xbee, it does not work as the vga signal is corrupted somehow.

posted by sanwal muneer 16 Dec 2012