Hello,

I am right now trying to implement a program that stores about 1700  
integers in an array, and once that array is full, a one shot timer is  
started and when the fired event occurs, the elements in the array are  
printed to the screen using printf and a for loop. I am trying to  
print out all 1700 elements in one for loop during one timer fired  
event. Initially I came across the problem that perhaps because the  
buffer size for printf is initialized to 250, it could only print out  
250 bits at a time. With that assumption I then tried making a program  
that in the Boot.booted() event, it would put 1700 integers in the  
array and then start a one shot timer. When the fired event occured,  
it would
print 250 bits from the array, and then once it finished printing  
those it would restart the one shot timer, so that it would print out  
the 1700 bits by triggering the one shot timer fired event 6 or 7  
times. However, even when I did this I came across a problem. If I set  
my timer to anything lower then 80 milliseconds, it would not print  
out all 1700 bits. Instead it would stop somewhere short of that, even  
though I have it only print 250 bits at a time. I can't seem to figure  
out what the problem is, and any help would be greatly appreciated. I  
attached the code to the bottom of this page:

#include "Timer.h"
#include "printf.h"

module NewFastTxUltraC
{
   uses interface Timer<TMilli> as Timer0;
   uses interface Boot;
   uses interface Random;
   uses interface GeneralIO as PortE6;
}

implementation
{
uint16_t a;
uint16_t i = 0;
uint16_t k = 0;
bool stop = 0;
uint16_t values[1700];

event void Boot.booted()
   {
        call PortE6.makeOutput();
         for(i = 0; i < 1700; i++)
        {
        a = call Random.rand16();
        if(a & 0x01)
                values[i] = 1;
        else
                values[i] = 0;
        }
        call Timer0.startOneShot(50);

   }


event void Timer0.fired()
{
i = k*250;
k++;
for(i; (i < k*250) && (i < 1700); i++)
{
printf("%u",values[i]);
printfflush();
if(i == 1700)
{
call Timer0.stop();
stop = 1;
return;
}
}
if(!stop)
call Timer0.startOneShot(50);
}

}

Thanks,
David Blumenfeld

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to