cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
argo_elec
Visitor
Visitor
7,651 Views
Registered: ‎03-24-2008

system clock in MicroBalze

help for this problem,
I have microblaze on a spartan3an starter kit at 50MHz of clk, and the software aplication program a simple counter, and I don't understand
because this counter is too slow in microblaze very very slow, perhaps the microblaze not working at 50MHz , as set in BSB, or committing mistake, thank you.
my source code is this below
******************************

#include "xparameters.h"

#include "xgpio.h"

#include "stdio.h"

#include "xutil.h"

#include "xuartlite.h"

#include "xspi.h"

 

//*********declaracion de variables****************

int AC_DC_GND, arturo=1, jose=0, status;

long ADC_CH1, ADC_CH2, contador=0;

//decalraciond e instancias para modulos***********

XGpio acoples;

XGpio estado;

XGpio platano;

XGpio ADC_12bit;

XSpi control_adc;

//inicializacion de instancias ********************

INICIACION_INSTANCIAS(){

XGpio_Initialize (&estado, XPAR_LEDS_8BIT_DEVICE_ID);

XGpio_Initialize (&ADC_12bit, XPAR_DATOS_CONVERSOR_DEVICE_ID);

XGpio_Initialize (&acoples, XPAR_DIPS_4BIT_DEVICE_ID);

XGpio_Initialize (&platano, XPAR_BTNS_4BIT_DEVICE_ID);

XSpi_Initialize (&control_adc, XPAR_CONTROL_CONVERSOR_DEVICE_ID);

XSpi_SetOptions (&control_adc, XSP_MASTER_OPTION);

XSpi_SetSlaveSelect (&control_adc, 0x1);

}

//*************************************************

 

int main(void){

INICIACION_INSTANCIAS();

arturo=1;

jose=0;

//status=status++;

while(1){

status=status++;

ADC_CH1 = XGpio_DiscreteRead (&ADC_12bit, 1);

ADC_CH2 = XGpio_DiscreteRead (&ADC_12bit, 2);

AC_DC_GND = XGpio_DiscreteRead (&acoples, 1);

XGpio_DiscreteWrite (&estado, 1, arturo);

XGpio_DiscreteWrite (&acoples, 2, AC_DC_GND);

XGpio_DiscreteWrite (&estado, 1, jose);

if(status <= 127){ XGpio_DiscreteSet(&estado, 1, 0x00); }else{XGpio_DiscreteSet(&estado, 1, 0xff); };

}

}

0 Kudos
Reply
5 Replies
brouhaha
Explorer
Explorer
7,627 Views
Registered: ‎08-14-2007

What frequency are you getting from the outptus?  You do realize that you're not going to get 50/256 MHz, right?  Your loop contains a bunch of function calls.  Even if they are inlined, they still each will expand to multiple instructions.
0 Kudos
Reply
argo_elec
Visitor
Visitor
7,604 Views
Registered: ‎03-24-2008

the output frequency is 50kHz only with this counter, is that I am calling many functions and that they take their time ,,,,, !!!,,,,, but then I do not understand as would microblaze in an acquisition of signals for two ports at high speed >4Mhz and save them in memory, if it works so slow !!!! help me.   thanks.
0 Kudos
Reply
brouhaha
Explorer
Explorer
7,590 Views
Registered: ‎08-14-2007

50 KHz is pretty good.  The 50 MHz system clock divided by the 256 counter is about 200 KHz, so if your output is 50 KHz that means that your loop is only taking four instructions per iteration, much better than I expected.  Those functions apparently must be inlines.

 

What kind of "ports" are you trying to acquire at 4 MHz?  If they're just a single bit each, you should probably build a shift register and holding register to collect 32 samples into a word, so the Microblaze can deal with them 32 bits at a time rather than one bit at a time.  If they're wider, e.g., 8 bits or more, you might need DMA.

 

The Microblaze isn't magic; by itself it can't do anything that any other 50 MHz RISC processor can't do.  If you need a 50 MHz processor to deal with a 4 MHz signal, that means you only get 12.5 instructions (on average) to deal with each sample, which isn't very much.  The benefit of Microblaze is that it's in an FPGA, so you can easily add additional hardware to it such as DMA controllers, shift registers, etc. 

0 Kudos
Reply
brouhaha
Explorer
Explorer
7,588 Views
Registered: ‎08-14-2007

By the way, is "status" really an int?  I wasn't looking closely enough at the code before, and assumed you were using a char or unsigned char, which would overflow every 256 counts.  An int is 32 bits (I think), so it would only overflow every four billion counts.

 

And you shouldn't write "status=status++"; the result of that is undefined.  Just write either "status++" or "status=status+1".

 

Also, "status" isn't really a very good name for a counter.  How about "count"?

 

0 Kudos
Reply
argo_elec
Visitor
Visitor
7,544 Views
Registered: ‎03-24-2008

excuse me, I am a novice in microblaze.

if I have done in the code to place "status = status +1 ", but in the port don't change, but if you put "status = + + status" in code "C" is the same instructuion, then if change the led in port

Additionally attempt to use a converter parallel 12-bit resolution at 20MS / s, which is why I am very confused with the microblaze.

DMA could use the reader's converter?

thank you very much for your help.
0 Kudos
Reply