We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Actually I have already written the code in C but how do i make it work on FPGA. what should be the library function added so that I could use all I/O function and Pointers and array.
In your simple application, the peripheral have only a few registers so you can declare a hardware register as:
// LED register definition:
#define LED_REG (*((volatile unsigned long *)(0x50000000UL)))
// Note: UL for unsigned long
volatile unsigned int loop_counter; // declared as global volatile so the compiler won't optimize it away.
int main(void)
{
while (1) {
loop_counter = 0x2FFFFF;
while (loop_counter !=0) loop_counter --;
LED_REG = 0xAA;
LED_REG = 0x55;
} // end while
}
If your peripheral contains multiple registers, the peripheral can be declared as a data structure as in examples in CMSIS.
But if you are not familiar with programming you can still declare the registers as individuals.
You still need to add vector table in the project. You can modify a startup code from existing Cortex-M microcontroller to swap the peripheral interrupt handler definitions.
Please do not use private message so that the university team can follow up if needed. Thanks.
I will be careful about private messaging.
I don't thing for creating data structure for since I have very few peripheral.
I wanted to initialize a section of memory from a data file(txt file ). Access it while running the program.
Hi
The above code you suggested put AA and 55 pattern at address 0x50000000UL. However I have need to initialize my memory with some data file(signal samples) and read the same from the code written in keil. Above code can be used for reading values from specific memory location But I want to store data in memory which I have as a txt file in my computer. when I run my program it read the txt file from computer memory. but how it would be stored in hardware memory which I am using on board.
I have asked my lecturer for arranging the training for it. He would surely contact ARM for it.
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.
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.
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.
I am having problem in sending data through UART. The way I am doing is
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.
>>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.
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