2009-03-09 10:29:50 Time between reading of spi
Samuel Coelho (BRAZIL)
Message: 70615
Hi all.
I have a BF527 Ezkit and uClinux 2008 R1.5-RC3.
I wrote a program test to read one AD over SPI. The program works fine.
I can change the clock of SPI in the config file of board (~/uClinux-dist-2008R1.5-RC3/linux-2.6.x/arch/blackfin/mach-bf527/boards/ezkit.c). If I change the SPI clock, the time between reads don't change.
My code:
...
fd = open("/dev/spi", O_RDWR);
if (fd < 0) {
perror("Error opening /dev/spi");
return 1;
} else {
printf("spi(%d) opened\n", fd);
}
for (i=0; i< loops; i++) {
status = read(fd, rbuf, len);
if (status < 0) {
perror("Error read");
if (fl) {
fclose(fl);
}
return 1;
}
if (status < len) {
fprintf(stderr, "Short read\n");
return 1;
}
fprintf(fl, "%d;", rbuf[0]);
}
My doubt is how can I set the time between reads of SPI.
Best regards, Samuel.
QuoteReplyEditDelete
2009-03-09 18:42:50 Re: Time between reading of spi
Mike Frysinger (UNITED STATES)
Message: 70629
so add a sleep() ?
QuoteReplyEditDelete
2009-03-10 15:42:16 Re: Time between reading of spi
Samuel Coelho (BRAZIL)
Message: 70720
Hi Mike.
Thanks for your answer.
I want reduce the time.
I took the writing in file (fprintf(fl, "%d;", rbuf[0]);) of loop and the time decreased.
But I don't know how control the time.
Regards, Samuel.
QuoteReplyEditDelete
2009-03-10 15:47:26 Re: Time between reading of spi
Mike Frysinger (UNITED STATES)
Message: 70722
there are delays caused by userspace overhead and working with other SPI devices
QuoteReplyEditDelete
2009-03-10 16:03:58 Re: Time between reading of spi
Samuel Coelho (BRAZIL)
Message: 70723
Ok, I understood.
Thanks Mike.