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

Design Start ARM Cortex-M0 - UART

Hi,

My professor asked me to do offline processing for signal. I think for that i would only require a processor core, memory and probably a UART.

  I have already built those hardware  from design kit.

I wanted to write  application code(in Keil) for my algorithm which takes data from memory  process it and store it  back into memory.

Since most of the design example(EDK) are in assembly but I m  more familiar with C  but addressing of  peripheral and  starting reset handler routine. I  do not know  how to write in C.   I did not use CMSIS also:(

Could you suggest some  thing which makes it easier

Parents
  • The easiest way to insert text data in a program image is to declare them as constant variables. For example:

    const char *my_string[] = {

        "Hello world\n",

        "I need more coffee\n"

      };

    Or if your data are values, you can define constant integer array. E.g.

    const unsigned int my_data[] = {

      0x123456,

      0x123457,

      0x123458

    };

    There are basic C programming techniques and are covered in many C programming books.

Reply
  • The easiest way to insert text data in a program image is to declare them as constant variables. For example:

    const char *my_string[] = {

        "Hello world\n",

        "I need more coffee\n"

      };

    Or if your data are values, you can define constant integer array. E.g.

    const unsigned int my_data[] = {

      0x123456,

      0x123457,

      0x123458

    };

    There are basic C programming techniques and are covered in many C programming books.

Children
  • Thanks for the reply

    I actually wrote my  entire code, but when i generate my  Hex file I get is something like this 

    :020000040000FA

    :10000000FCFF000097060000000000000000000058

    :100010000000000000F002F800F040F80CA030C82A

    :10002000083824182D18A246671EAB4654465D4674

    :10003000AC4201D100F032F87E460F3E0FCCB646FE

    :100040000126334200D0FB1AA246AB463343184781

    Which I guess is not correct. I chose thumb mode in setting and also  included the vector table.  In my code I used 64 KB of on chip ROM and 64KB of on chip RAM.

  • This is Intel hex file format. If you want to use a hex file for Verilog simulation, you need to use Verilog hex.

    You can do this using fromelf utility in Keil MDK. For example, if the memory array is declared as four byte arrays, you can use:

    fromelf --vhx --8x4 image.elf –output itcm

    More details can be found here

    ARM Compiler toolchain Using the fromelf Image Converter: fromelf command reference

    ARM Information Center

    You can add this command in the user tab of your Keil MDK project option so that it execute automatically after a compilation.

  • Hi,

      Varoius peripheral like UART and AHB2LED are given a memory space of 16 MB. it is a memory mapped I/o where each peripheral  is treated as a memory address so why does it is given a 16 MB space.

  • Hi,

    I am having problem in sending data through UART. The way I am doing is

    #define AHB_UART_BASE(*((volatile unsigned long *)(0x51000000)))

    and In the  main code part I am simply putting a value into that location

    AHB_UART_BASE=c;

    while running it is not showing the  value of c. My UART in FPGA is connected to serial port on my pc. I  am using AHB2UART module.  Transferring data from Memory to UART that is also not working.

  • Hi

    >>Varoius peripheral like UART and AHB2LED are given a memory space of 16 MB. it is a memory mapped I/o where each peripheral  is treated as a memory address so why does it is given a 16 MB space.

    The 16MB memory space is just an example, and it can customised to any size depending on your needs.

    >>My UART in FPGA is connected to serial port on my pc. I  am using AHB2UART module.  Transferring data from Memory to UART that is also not working.

    Did you define c as a char type, and is it in ASCII format?

    Also if you send multiple data to UART, you need to check the UART status register to see if the FIFO is full, the address of the status register is 0x51000004, you can have a look at the verilog file for more detail.

    Cheers

  • I have defined C as unsigned integer type. I am transferring only 4 unsigned integer values. I checked the UART module. it has a FIFO of depth 16  FIFO  begin Full  may not be the case.

    Could you provide any study material available online for h/w development (verilog part).  I searched on internet not  much is available for building h/w development using cortex M0 IP core. I have implemented few of the design start example. But I am facing difficulty when I interfacing various modules for my requirement.

  • I am sorry  for above comment not making sense.

    In the above comment. I mean to say. FIFO has depth of 16 so FIFO being full might not be the case.

  • Have you done any simulation to check? Is it not working in simulation? or just hardware?

    There are several areas to check:

    - bus level integration

    - baud rate (how is the system clock divided into the baud rate you expected)? What is the baud rate setting on PC?

    - FPGA pin assignment

    - UART connection (TX data and RX data pin definition on PC and MCU might need a cross over connection)

    - The configuration of UART on your PC. Some PC don't have UART and therefore you might be using a USB to UART adaptor. Have the device driver installed sucessfully? Try a loop back connection to test.

    - TTL to RS232 converter might be needed.

  • Hi,

    I guess most of the things I checked.

    FPGA pin assignment ok.

    -driver of UART  for FPGA installed and also recognized by the PC.

    -tera-term application is intalled as well.

    -As specify the UART  baud rate 19200. GCLK=100Mhz,  HCLK=10MHZ. and baud rate=19200. with (10/19200*16)=32 as count value in baud rate generator.

    In simulation I checked. I guess not worked there. 

     

  • Can you post your program code?

    -          UART registers declarations

    -          How you initialize the UART

    -          The test sequence (how you sent data to UART)

    Thanks

  • For a simple case I just tried to  send a single value as shown.

    #include "stdio.h"

    #define AHB_UART_BASE (*((volatile unsigned long *)(0x51000000)))

    int  main ()

    {

    int a,b,c;

    a=6;

    b=5;

    c=a+b;

    AHB_UART_BASE=c;

    return 0;

    }


    ///Vector table for program. 



    / Define where the top of memory is.

    #define TOP_OF_RAM 0xFFC

    extern int main(void);     // Use C-library initialization function.

    __attribute__ ((section("__Vectors")))

    static void (* const vector_table[])(void) =

    {

      (void (*)(void)) TOP_OF_RAM, // Initial value for stack pointer.

      (void (*)(void)) main,                      // Reset handler is C initialization.

      0,                           // No HardFault handler, just cause lockup.

      0,                           // No NMI handler, just cause lockup.

      0,

      0,

      0,

      0,

      0,

      0,0,0,0,0,0,0//...                       // Additional handlers would be listed here.

      (void) UART_handler

     

    };

  • Sorry for the delay.

    You write the character with value of 11 (0xB) to the UART. However, this might not be a character that can be displayed on your terminal.

    So please try

    AHB_UART_BASE='A'; // Character 'A'

    Another issue is that the main() is finished after you send out the character.

    You might want to add a dead loop :

    int  main (void)

    {

    AHB_UART_BASE='A';

    while(1); // deadloop

    return 0;

    }


    Hope this helps.