* [ECOS] how to get minimum resolution
@ 2007-08-10 12:19 sandip
2007-08-10 14:01 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: sandip @ 2007-08-10 12:19 UTC (permalink / raw)
To: ecos-discuss
dear friend
I am working on sam7x board ,I am going to implementing seven segment on
that .
in my program I am using alarm for display update with minimum time..
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
I want update time == 20ms.
but I didn't get sufficient time for display update so display will
flickering.
can any one give suggestion how to update display with minimum time.
regards
Sandip
-------------------------------------------------------
Masibus Process Instruments (P) Ltd, Gandhinagar, India
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ECOS] how to get minimum resolution
2007-08-10 12:19 [ECOS] how to get minimum resolution sandip
@ 2007-08-10 14:01 ` Andrew Lunn
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2007-08-10 14:01 UTC (permalink / raw)
To: sandip; +Cc: ecos-discuss
On Fri, Aug 10, 2007 at 05:36:32PM +0530, sandip wrote:
> dear friend
>
> I am working on sam7x board ,I am going to implementing seven segment on
> that .
>
> in my program I am using alarm for display update with minimum time..
>
> cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
>
> I want update time == 20ms.
>
> but I didn't get sufficient time for display update so display will
> flickering.
What do you mean you don't get sufficient time for display update? Do
you mean it takes longer than 20ms for you to reprogram the PIO
registers? Or do you mean you don't get timers fired with an interval
of 20ms?
Please show us your code and give a more detailed description.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ECOS] how to get minimum resolution
2007-08-11 4:29 sandip
@ 2007-08-11 8:06 ` Andrew Lunn
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2007-08-11 8:06 UTC (permalink / raw)
To: sandip; +Cc: ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 830 bytes --]
On Sat, Aug 11, 2007 at 09:32:33AM +0530, sandip wrote:
> dear friend ,
>
> here i send my code, using alarm i am going to drive seven segment display.
> cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
> using this i provide minimum delay and function call in short time.but i
> didn't get small delay.
Try this version. You should see output like:
ticks: 1000, alarms: 1000, alarms/second: 100
ticks: 2000, alarms: 2000, alarms/second: 100
ticks: 3000, alarms: 3000, alarms/second: 100
ticks: 4000, alarms: 4000, alarms/second: 100
ticks: 5000, alarms: 5000, alarms/second: 100
ticks: 6000, alarms: 6000, alarms/second: 100
ticks: 7000, alarms: 7000, alarms/second: 100
ticks: 8000, alarms: 8000, alarms/second: 100
I've not tried it on the sam7x, but i expect it to pretty similar.
Andrew
[-- Attachment #2: ticks.c --]
[-- Type: text/x-csrc, Size: 1377 bytes --]
#include <cyg/kernel/kapi.h>
#include <cyg/infra/diag.h>
#define HZ 100
/* test_alarm_func() is invoked as an alarm handler. so
Increments the data that is passed to it. */
void
test_alarm_func(cyg_handle_t alarmH, cyg_addrword_t data)
{
++*((unsigned *) data);
}
/* Entry point. Setup and alarm, and then print how often it gets
called per second */
int
main(const int argc, const char * argv[])
{
cyg_handle_t test_counterH, test_alarmH;
cyg_alarm test_alarm;
cyg_uint32 alarm_count = 0;
/* Get the counter associated to the real time clock. */
cyg_clock_to_counter(cyg_real_time_clock(), &test_counterH);
/* Create an alarm */
cyg_alarm_create(test_counterH, test_alarm_func,
(cyg_addrword_t) &alarm_count,
&test_alarmH, &test_alarm);
/* Initialize the alarm to trigger once per system tick,
recurring. */
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
/* Every so often, print out how many alarms per second we are
achieving. */
for (;;) {
cyg_uint32 alarms;
cyg_uint32 ticks;
cyg_thread_delay(10 * HZ);
cyg_scheduler_lock();
alarms = alarm_count;
ticks = cyg_current_time();
cyg_scheduler_unlock();
diag_printf("ticks: %5d, alarms: %5d, alarms/second: %3d\n",
ticks, alarms, alarms/(ticks/HZ));
}
}
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ECOS] how to get minimum resolution
@ 2007-08-11 4:29 sandip
2007-08-11 8:06 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: sandip @ 2007-08-11 4:29 UTC (permalink / raw)
To: ecos-discuss
dear friend ,
here i send my code, using alarm i am going to drive seven segment display.
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
using this i provide minimum delay and function call in short time.but i
didn't get small delay.
i think test_alarm_func() awke every 30 milisecond.
how can i reduce time of alarm.
In our other product we are using timer interrupt for update seven-segment
at 50HZ
and how to use timer interrupt in ECOS.
#include <cyg/kernel/kapi.h>
#include <stdio.h>
#include <cyg/io/io.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/io/serialio.h>
# include <cyg/hal/hal_platform_ints.h>
#define NTHREADS 1
#define STACKSIZE 4096
#define alfabets 0x00000057
#define alfabeta 0x000000cf
#define alfabetn 0x0000004c
#define alfabetd 0x000000dc
#define alfabety 0x000000d6
#define anode1 0x00000100
#define anode2 0x00000200
#define anode3 0x00000400
#define anode4 0x00000800
#define anode5 0x00001000
static cyg_handle_t thread[NTHREADS];
static cyg_thread thread_obj[NTHREADS];
static char stack[NTHREADS][STACKSIZE];
cyg_uint32 i = 128;
cyg_uint32 j = 0;
cyg_uint32 k[5] = {0x00000057,0x000000cf ,0x0000004c ,0x000000dc
,0x000000d6 };
static void alarm_prog( cyg_addrword_t data );
/* we install our own startup routine which sets up
threads and starts the scheduler */
void cyg_user_start(void)
{
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_PER,0x00ffffff);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_OER,0x00ffffff);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_SODR,0x00ffffff);
cyg_thread_create(4, alarm_prog, (cyg_addrword_t) 0,
"alarm_thread", (void *) stack[0],
STACKSIZE, &thread[0], &thread_obj[0]);
cyg_thread_resume(thread[0]);
}
/* we need to declare the alarm handling function (which is
defined below), so that we can pass it to
cyg_alarm_initialize() */
cyg_alarm_t test_alarm_func;
/* alarm_prog() is a thread which sets up an alarm which is then
handled by test_alarm_func() */
static void alarm_prog(cyg_addrword_t data)
{
cyg_handle_t test_counterH, system_clockH, test_alarmH;
cyg_tick_count_t ticks;
cyg_alarm test_alarm;
unsigned how_many_alarms = 0, prev_alarms = 0, tmp_how_many;
system_clockH = cyg_real_time_clock();
cyg_clock_to_counter(system_clockH, &test_counterH);
cyg_alarm_create(test_counterH, test_alarm_func,
(cyg_addrword_t) &how_many_alarms,
&test_alarmH, &test_alarm);
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
/* get in a loop in which we read the current time and
print it out, just to have something scrolling by */
for (;;) {
ticks = cyg_current_time();
//printf("Time is %llu\n", ticks);
/* note that we must lock access to how_many_alarms, since the
alarm handler might change it. this involves using the
annoying temporary variable tmp_how_many so that I can keep the
critical region short */
cyg_scheduler_lock();
tmp_how_many = how_many_alarms;
cyg_scheduler_unlock();
if (prev_alarms != tmp_how_many) {
//printf(" ---> alarm calls so far: %u\n", tmp_how_many);
prev_alarms = tmp_how_many;
}
cyg_thread_delay(30);
}
}
/* test_alarm_func() is invoked as an alarm handler, so
it should be quick and simple. in this case it increments
the data that is passed to it. */
void test_alarm_func(cyg_handle_t alarmH, cyg_addrword_t data)
{
++*((unsigned *) data);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_SODR,0x00ffffff);
HAL_WRITE_UINT32(AT91_PIOB + AT91_PIO_CODR,k[j]|i*2);
i=i*2;
if(i>2049)
i=128;
j++;
if(j == 5)
j=0;
}
-------------------------------------------------------
Masibus Process Instruments (P) Ltd, Gandhinagar, India
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-11 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-10 12:19 [ECOS] how to get minimum resolution sandip
2007-08-10 14:01 ` Andrew Lunn
2007-08-11 4:29 sandip
2007-08-11 8:06 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).