Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Actel SmartFusion beginners question

Status
Not open for further replies.

JQadrad

Newbie level 3
Joined
Mar 12, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
Hey guys,

I recently bought the Actel SmartFusion A2F-EVAL-KIT to start my experience with FPGA developing. I read through the workflow tutorials and I understand how the different programs are used. Right now I want to make a simple program which reads a string in the HyperTerminal and displays the string on the OLED or echoes it in the HyperTerminal. I used the OLED-tutorial to try to understand the readchar() function, but when I display this character it doesn't show me 1 when I press a 1. I can't even get a single character, so reading a string will be the next challenge. I was thinking about filling a buffer with characters, but since I don't have the characters yet..

The second problem is that I tried to hardcopy a string in the program and search through this string character wise, but also this seems to fail.

My question to you is if you maybe can show me how this is done? Does anyone have a simple example or can you point me in the right direction on how to read characters/strings and have them in the right format?

Thanks in advance,

JJ
 

Your question is vague; I'll try to guess what you are asking....

I'm assuming you are learning VHDL, and want to send strings typed in hyperterminal to the FPGA dev board via it's integrated USB to serial converter and either display them on the OLED or echo them back to Hyperterminal.

You need to read up on the serial protocol and design a simple VHDL UART to rx and tx the bits from the integrated serial port. IT's not that difficult to do and will teach you a lot. You could use some UART IP but wont learn anything about what is going on underneath.

You need to read up on the OLED interface and learn that too; its a transferrable skill and worth learning, they all work pretty much the same.


then design a simple state machine that goes through teh following states:
reset OLED and uart
initialise OLED ( you will need write several bytes to teh oled)
wait for characters to appear via your UART
dump new character to OLED (and UART if required)
go back to wait for character state

Again, you could embed a soft core processor and do it all with C but you seem to be learning VHDL, not a programming language.

Hope this helps some
 

Hi drmorbius,

Thank you for your reply. Sorry for the vague question. Actually I am working with C right now and running the code on the FPGA. I just managed to create a string reading from the buffer with the following code

Code:
#include <string.h>
#include <stdlib.h>

#include "drivers/mss_uart/mss_uart.h"

#define RX_BUFF_SIZE 	1
#define MAX_LENGTH		20

void processInput(uint8_t buffer[RX_BUFF_SIZE]);
void printNewLine();

uint8_t rx_buff[RX_BUFF_SIZE];
uint8_t newline[2] = "\r\n";
int c = 0;
uint8_t stopInput = 0;
uint8_t inputString[80];

int main( void )
{
	const uint8_t opening[] = "\r\n-- Random software --\r\n";
	const uint8_t stringComplete[] = "\r\nYou entered the following string: \r\n";
	const uint8_t ending[] = "\r\nThat's it! \r\n";
    MSS_UART_init
         (
            &g_mss_uart0,
            MSS_UART_57600_BAUD,
            MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT
       );
    // Say hello
	MSS_UART_polled_tx( &g_mss_uart0, opening, sizeof(opening) );
	// Loop till buffer is full or enter is pressed
	while(stopInput == 0)
	{
	   uint8_t rx_size = 0;
	   rx_size = MSS_UART_get_rx( &g_mss_uart0, rx_buff, sizeof(rx_buff) );
       if (rx_size > 0)
       {
    	   processInput(rx_buff);
       }
	}
	inputString[c] = '\0';
	MSS_UART_polled_tx( &g_mss_uart0, stringComplete, sizeof(stringComplete) );
	MSS_UART_polled_tx( &g_mss_uart0, inputString, c );
	printNewLine();
	int l = 0;
	int currentChar;
	for(l = 0; l < c; l++){
		currentChar = inputString[l];
		//MSS_UART_polled_tx( &g_mss_uart0, inputString[l], sizeof(inputString[l]) );
		MSS_UART_polled_tx( &g_mss_uart0, currentChar, sizeof(currentChar) );
	}
	MSS_UART_polled_tx( &g_mss_uart0, ending, sizeof(ending) );
	return 0;
}
void processInput(uint8_t buffer[RX_BUFF_SIZE]){
	if(c < MAX_LENGTH){
		if(buffer[0] == 13){ // Enter is pressed
			stopInput = 1;
		}else{
			MSS_UART_polled_tx( &g_mss_uart0, buffer, sizeof(buffer) );
			inputString[c] = buffer[0];
			c++;
		}
	}else{ // Buffer is full
		stopInput = 1;
	}
}
void printNewLine(){
	MSS_UART_polled_tx( &g_mss_uart0, newline, sizeof(newline));
}

This seems to work and the string is created by pressing keys in the HyperTerminal. I hope this codes explains what I am doing. I don't know if this is the best way to do it, but for now it seems to work. The next problem I encounter is I can't loop through the string as I can in C on my normal machine. Normally you can get a character from a string (character array) by
Code:
char temp = string[i];
but this doesn't seem to work here. The currentChar in the for loop gets the right ASCII value, but when I print it using the MSS_UART_polled_tx function it gives the warning 'pointer from integer without cast' problem.

Any suggestions to improve my code and how to go through the string?

(In this code I don't use the OLED yet, since it is only extra)
 

if you're using C, there is clearly a microprocessor on the FPGA. You do not compile C code directly to an FPGA.
 

Hi drmorbius,

Thank you for your reply. Sorry for the vague question. Actually I am working with C right now and running the code on the FPGA. I just managed to create a string reading from the buffer with the following code

Code:
#include <string.h>
#include <stdlib.h>

#include "drivers/mss_uart/mss_uart.h"

#define RX_BUFF_SIZE 	1
#define MAX_LENGTH		20

void processInput(uint8_t buffer[RX_BUFF_SIZE]);
void printNewLine();

uint8_t rx_buff[RX_BUFF_SIZE];
uint8_t newline[2] = "\r\n";
int c = 0;
uint8_t stopInput = 0;
uint8_t inputString[80];

int main( void )
{
	const uint8_t opening[] = "\r\n-- Random software --\r\n";
	const uint8_t stringComplete[] = "\r\nYou entered the following string: \r\n";
	const uint8_t ending[] = "\r\nThat's it! \r\n";
    MSS_UART_init
         (
            &g_mss_uart0,
            MSS_UART_57600_BAUD,
            MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT
       );
    // Say hello
	MSS_UART_polled_tx( &g_mss_uart0, opening, sizeof(opening) );
	// Loop till buffer is full or enter is pressed
	while(stopInput == 0)
	{
	   uint8_t rx_size = 0;
	   rx_size = MSS_UART_get_rx( &g_mss_uart0, rx_buff, sizeof(rx_buff) );
       if (rx_size > 0)
       {
    	   processInput(rx_buff);
       }
	}
	inputString[c] = '\0';
	MSS_UART_polled_tx( &g_mss_uart0, stringComplete, sizeof(stringComplete) );
	MSS_UART_polled_tx( &g_mss_uart0, inputString, c );
	printNewLine();
	int l = 0;
	int currentChar;
	for(l = 0; l < c; l++){
		currentChar = inputString[l];
		//MSS_UART_polled_tx( &g_mss_uart0, inputString[l], sizeof(inputString[l]) );
		MSS_UART_polled_tx( &g_mss_uart0, currentChar, sizeof(currentChar) );
	}
	MSS_UART_polled_tx( &g_mss_uart0, ending, sizeof(ending) );
	return 0;
}
void processInput(uint8_t buffer[RX_BUFF_SIZE]){
	if(c < MAX_LENGTH){
		if(buffer[0] == 13){ // Enter is pressed
			stopInput = 1;
		}else{
			MSS_UART_polled_tx( &g_mss_uart0, buffer, sizeof(buffer) );
			inputString[c] = buffer[0];
			c++;
		}
	}else{ // Buffer is full
		stopInput = 1;
	}
}
void printNewLine(){
	MSS_UART_polled_tx( &g_mss_uart0, newline, sizeof(newline));
}

This seems to work and the string is created by pressing keys in the HyperTerminal. I hope this codes explains what I am doing. I don't know if this is the best way to do it, but for now it seems to work. The next problem I encounter is I can't loop through the string as I can in C on my normal machine. Normally you can get a character from a string (character array) by
Code:
char temp = string[i];
but this doesn't seem to work here. The currentChar in the for loop gets the right ASCII value, but when I print it using the MSS_UART_polled_tx function it gives the warning 'pointer from integer without cast' problem.

Any suggestions to improve my code and how to go through the string?

(In this code I don't use the OLED yet, since it is only extra)

Maybe I think, for validating your C-Code very well, you should post in "Embedded Systems and Real-Time OS" board. Once you get the idea, come back here and post for implementation in FPGA device....
 

Thanks for the reply. For now I will first play around with the code a bit more before I start to ask too many stupid questions. If I have more questions I will post them in the other board =)
 

I could see you saying
I recently bought the Actel SmartFusion A2F-EVAL-KIT to start my experience with FPGA developing

If you are trying to learn FPGA, why is that you want to look into C code and embedded oriented programs?. Ofcourse FPGA foundation is required for FPGA based soft processor devs. Just asking out of interest....
 

I just followed the tutorials from the Actel website, which involve writing C-code (with specific function calls to the Microcontroller subsystem) to run on the board. The tutorials I followed didn't involve any VHDL or whatsoever.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top