UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Participant sshilpa
Participant
19,916 Views
Registered: ‎02-12-2008

microblaze, sleep()

Jump to solution

Hi

 

Am using EDK 11.1 and microblaze is the processor.

I need to use sleep() in my software program.

What is the syntax and the corresponding header file for the sleep function?

 

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Xilinx Employee
Xilinx Employee
26,479 Views
Registered: ‎08-07-2007

Re: microblaze, sleep()

Jump to solution

Hi

 

MicroBlaze doesn't have a timer. So no sleep() function without a timer.

 

You can add a timer into the system and implement your sleep() function.

 

-XF

0 Kudos
7 Replies
Highlighted
Xilinx Employee
Xilinx Employee
26,480 Views
Registered: ‎08-07-2007

Re: microblaze, sleep()

Jump to solution

Hi

 

MicroBlaze doesn't have a timer. So no sleep() function without a timer.

 

You can add a timer into the system and implement your sleep() function.

 

-XF

0 Kudos
Adventurer
Adventurer
19,896 Views
Registered: ‎08-16-2007

Re: microblaze, sleep()

Jump to solution

The sleep function is available if you use XMK and of course has to be configured to include a timer.

unsigned sleep(unsigned int ms)

Parameters
ms is the number of milliseconds to sleep.
Returns Number of seconds between sleeps.
0 on complete success.
Description This routine causes the invoking process to enter a sleep state for the
specified number of milliseconds.
Includes
xmk.h, sys/timer.h

BR

0 Kudos
Participant sshilpa
Participant
19,877 Views
Registered: ‎02-12-2008

Re: microblaze, sleep()

Jump to solution

 

 

Thanks for the reply.

 

regards,

Shilpa

0 Kudos
Explorer
Explorer
19,586 Views
Registered: ‎01-09-2009

Re: microblaze, sleep()

Jump to solution

Is it possible to use sleep function without using XMK?

 

I am using microbalze, ISE 11.3, and virtex-5.

0 Kudos
Xilinx Employee
Xilinx Employee
19,581 Views
Registered: ‎08-06-2007

Re: microblaze, sleep()

Jump to solution

Hi,

 

Not really since sleep function it's part of the XMK and it requires a timer.

 

You can however create your own sleep function by using FSL and a hardware counter

Just create a loadable 32-bit counter, connect a master fsl data as the loadable value and a master fsl write signal as the load signal.

Make sure that the counter has a signal which is '1' when it reach 0 and that it stops counting when it reach zero.

Connect this signal to a master slave exist input on MicroBlaze.

 

If you now want to sleep (stalling), just execute a put instruction with the sleep value and then do a blocking get.

This will make MicroBlaze stall until the counter has reach zero.

 

If you enable the extended FSL support, MicroBlaze can still handle interrupts while sleeping.

 

Göran

 

 

Explorer
Explorer
19,464 Views
Registered: ‎01-09-2009

Re: microblaze, sleep()

Jump to solution

Göran,

 

Your solution was so elegant. Thanks! I implemented a sleep function using blocking FSL.

 

Now, I need to support interrupts while sleeping. Can you point me to some references regarding "extended FSL support".

 

Thanks,

--

aminfar

 

0 Kudos
Xilinx Employee
Xilinx Employee
19,453 Views
Registered: ‎08-06-2007

Re: microblaze, sleep()

Jump to solution

Hi,

 

Just set C_USE_EXTENDED_FSL_INSTR = 1 on MicroBlaze.

This will make the blocking fsl instructions interruptable.

MicroBlaze will jump to the interrupt handler while it's stalling on a blocking FSL instruction and jump back to the blocking FSL instruction when the interrupt handler returns with "RTID" instruction.

Don't forget to enable interrupts.

 

Göran

0 Kudos