EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Ezurio's UWScript and LPC2104

Started by AlexandreD June 30, 2009
Hi all,

I'm working on an application with a LPC2104 storing data on a memory
card, which is connected through RS232 (using only the ground, TX and RX)
to an Ezurio's WIFI module. I programmed the microcontroller using C, and
when I connect it on a computer to check whether it is working, everything
is OK. Same goes for the WIFI module, programmed using Ezurio's UWScript.
However, when I connect them together, the WIFI module can get the data
sent by the microcontroller, but the microcontroller never gets the
response from the module, and the program is blocked on the reading
function.

These are codes I wrote to test if I could make it work :

WIFI module, UWScript :
ULONG ubaud
UWORD ubits
UWORD uparity
UWORD ustop
UWORD upersist
ubaud=115200
ubits=8
uparity=0
ustop=1
upersist=1
_UARTMODIFY (ubaud, ubits , uparity, ustop, upersist)
string test
slong end
endfile = H'FFFFFFFF
plouf="hello\r\n\0"
print test;endfile
while 1
endwhile


LPC2104, C :
int main( void){
    (void)SetNativeSpeed( 10000uL ); 		// Quartz
    (void)SetMAM( 3u, MAM_full_enable );	// MAM
    (void)SetDesiredSpeed( 60000uL);		// CPU
    (void)VPBControl( VPB_DIV2 );		// Vitesse périph

    // Configuration liaison port série (Vers Wifi/PC) 
    struct serial_param sp;
    sp.baud   = 115200uL;
    sp.length = UART_WORD_LEN_8;
    sp.parity = UART_PARITY_NONE;
    sp.stop   = UART_STOP_BITS_1;
    (void)ioctl( fileno(WIFI_out), UART_SETUP, &sp); //WIFI_out is stdout
    (void)ioctl( fileno(WIFI_in),  UART_SETUP, &sp); //WIFI_in is stdin
    (void)StartClock();

    char* test;
    char bla[30];
    test = (char*)malloc(1024*sizeof(char));
    strcpy(test,"");
    fprintf(WIFI_out,"AT+RUN \"azerty\"\r"); //Run the script
    fflush(WIFI_out);
    int c;
    int i=0;
   while (i<=10)
   {
      i++;
      c = fgetc (WIFI_in);
      if (isprint (c))
      {
         sprintf (bla,"'%c'  (0x%02X)\t", c, (unsigned) c);
         strcat(test,bla);
      }
      else
      {
         switch (c)
         {
         case '\n':
            sprintf ( bla,"'\\n' (0x%02X)\t", (unsigned) c);
            strcat(test,bla);
            break;
         case '\t':
            sprintf (bla,"'\\t' (0x%02X)\t", (unsigned) c);
            strcat(test,bla);
            break;
         default:
            sprintf (bla,"??  (0x%02X)\t", (unsigned) c);
            strcat(test,bla);
         }
      }
   }
    //This loop is for debug : when the LPC2104 should have got the
characters, I connect it to the computer.
    while(1){
    fprintf(WIFI_out,"%s",test);
    fflush(WIFI_out);
    }
}


The script runs perfectly, and is blocked in the infinite while loop, but
the microcontroller doesn't receive anything, and remains blocked on the
first fgetc(), waiting for characters...

The most surprising is that I was told that the system already worked, but
when I tested the programs, nothing happened.
Can anyone figure out where my problem is ?

Thank you all,
Alexandre.



Memfault Beyond the Launch