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

Receiving Data Using the UART CORTEX M0

Hi, I wanted to write a simple program that doesn’t use interrupts or check any of the possible error flags, but that shows a simple UART application for receiving data. This is a part of the code I wrote.


int uart0Getch(void)

{

  if (LPC_UART->LSR & LSR_RDR)                 // check if character is available

  { return LPC_UART->RBR;                       // return character

  }

  return -1;

}

#include "includes.h"

#include "uart.h"

int value;

extern int main( void )

{

 

  system_init();

screen1[0]='a';

  screen1[1]='b';

  screen1[2]='c';

  while(1)

 

  //KeyScanProc(buf,screen1);

  

  if ((value = uart0Getch()) >= 0)

  {

  send_to_uart(screen1,3);

  }

  }

  }

}

Parents
  • Looking at the code snippet you posted, I think your 'while(1)' could be the problem.

    -But something is wrong with the snippet; it does not contain a balanced set of curly braces, so it's difficult to guess where they are in your original code.

    You should make sure that there is a starting brace right after your 'while(1)'

    For instance...

    int main(void)

    {

      // some initialization code here.

      while(1)

      {

         // your code here.

      }

    // no code here.

    }

    Notice: the 'extern' keyword in front of 'int main(void)' should also be removed.

Reply
  • Looking at the code snippet you posted, I think your 'while(1)' could be the problem.

    -But something is wrong with the snippet; it does not contain a balanced set of curly braces, so it's difficult to guess where they are in your original code.

    You should make sure that there is a starting brace right after your 'while(1)'

    For instance...

    int main(void)

    {

      // some initialization code here.

      while(1)

      {

         // your code here.

      }

    // no code here.

    }

    Notice: the 'extern' keyword in front of 'int main(void)' should also be removed.

Children