This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem when transmitting the a string data to GPS interface with 8051 uC

void main(void)
{
        unsigned short  l_us_temp;
        //Disable watchdog timer
        WDTCN = 0xDE;
   WDTCN = 0xAD;

        ExtCrystalOsc_Init();

        //Initialise crossbar and GPIO
        Port_Init();

        EMIF_Init();

        //Initialise Timer 0
        Timer0_Init();

        //Initialise Timer 2
        Timer2_Init();

        //Initialise Timer 4
        Timer4_Init();

        //Initialise UART0
        UART0_Init();

        //Initialise UART1
        UART1_Init();

        //Initialise ADC
        ADC0_Init();

        //Initialise DAC
        DAC0_Init();
        DAC1_Init();

        //Initialise PCA0
        PCA0_Init();

        //Initialise INT0_N & INT1_N
        Ext_Interrupt_Init();

//lsl : 04 Jan 2011 : 0852hrs : disable Watchdog timer temporarily
        //Initialise Watchdog Timer
//      Watchdog_Init();

        //Initialise SPI0
        SPI0_Init();

        //------------------------
        //Reset IMU-A, IMU-B & GPS

   SFRPAGE = CONFIG_PAGE;

        IMU_A_CS = 1;
        IMU_B_CS = 1;

        IMU_A_RST = 0;
        IMU_B_RST = 0;

        GPS_RST = 0;

        delay_ms(1);

        IMU_A_RST = 1;
        IMU_B_RST = 1;

        GPS_RST = 1;

        delay_ms(1);

        //---------------------------------------------------------
        //lsl : 31 Dec 2010 : 1046hrs: Initialise variables : begin

        g_us_rx0_ptr = 0;
        g_us_tx0_ptr = 0;
        g_us_rd0_ptr = 0;

        for (l_us_temp = 0 ; l_us_temp < RX_BUFFER_SIZE ; l_us_temp++)
        {
                g_c_rx0_buffer[l_us_temp] = 0;
        }

        g_us_rx1_ptr = 0;
        g_us_tx1_ptr = 0;
        g_us_rd1_ptr = 0;

        for (l_us_temp = 0 ; l_us_temp < RX_BUFFER_SIZE ; l_us_temp++)
        {
                g_c_rx1_buffer[l_us_temp] = 0;
        }

        //lsl : 05 Jan 2011 : 1916hrs : tested
        UART1_Buffer = "\rlog version\r\n";
        g_us_tx1_cmd_length = 14;

        //lsl : 06 Jan 2011 : 1916hrs : tested ok
        //UART1_Buffer = "frequencyout enable 2 4\r\n";
        //g_us_tx1_cmd_length = 25;

        g_uc_gps_init = 0;

        //Enable global interrupts
        EA = 1;

        //-----------------------------------------------------------------------------
        // Start of WHILE LOOP
        //-----------------------------------------------------------------------------

   while (1)
        {
                //Toggle LED_1 & LED_2
           SFRPAGE = CONFIG_PAGE;
                LED_1 ^= 1;
                LED_2 ^= 1;

                           }

        //-----------------------------------------------------------------------------
        // End Of WHILE LOOP
        //-----------------------------------------------------------------------------
}

I could not able to transmit the data through the UART when i run the program. But when i put a breakpoint, it seems working fine. May i know where is the problem? i seems like i could not find it. thanks

Parents
  • If you can't find it when you have all the code and the hardware right there in front of you, how on earth do you expect anyone else to find it who does not have the code, and does not know your hardware??

    You have not shown any code that has anything to do with transmitting from the UART!

            //lsl : 06 Jan 2011 : 1916hrs : tested ok
            //UART1_Buffer = "frequencyout enable 2 4\r\n";
            //g_us_tx1_cmd_length = 25;
    


    What does "tested ok" mean here?

    Did it work once, and you have broken it?

            //lsl : 05 Jan 2011 : 1916hrs : tested
            UART1_Buffer = "\rlog version\r\n";
            g_us_tx1_cmd_length = 14;
    


    Again, what does "tested" mean here?
    What test? What was the result of the test?

    Why are you setting the length as a "Magic Number"?
    This is asking for trouble!
    Why not use strlen instead??

    "when i put a breakpoint, it seems working fine"

    Suggests a timing problem, don't you think...?

Reply
  • If you can't find it when you have all the code and the hardware right there in front of you, how on earth do you expect anyone else to find it who does not have the code, and does not know your hardware??

    You have not shown any code that has anything to do with transmitting from the UART!

            //lsl : 06 Jan 2011 : 1916hrs : tested ok
            //UART1_Buffer = "frequencyout enable 2 4\r\n";
            //g_us_tx1_cmd_length = 25;
    


    What does "tested ok" mean here?

    Did it work once, and you have broken it?

            //lsl : 05 Jan 2011 : 1916hrs : tested
            UART1_Buffer = "\rlog version\r\n";
            g_us_tx1_cmd_length = 14;
    


    Again, what does "tested" mean here?
    What test? What was the result of the test?

    Why are you setting the length as a "Magic Number"?
    This is asking for trouble!
    Why not use strlen instead??

    "when i put a breakpoint, it seems working fine"

    Suggests a timing problem, don't you think...?

Children