View previous topic :: View next topic |
Author |
Message |
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Thu May 24, 2018 12:37 pm |
|
|
I think last time I just used a delay_us(1) and then toggled an output and watched the frequency on a scope. Is there a better way to test the speed? I really hope I have not been running slower than I thought this whole time! Man the old 8 bit days were so easy. ;) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19238
|
|
Posted: Thu May 24, 2018 12:46 pm |
|
|
Problem with that is the delays involved in the actual output operations. Do a toggle at a much longer interval like 10 seconds, and you can check with a stopwatch. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Thu May 24, 2018 1:18 pm |
|
|
Then I guess that takes any instruction lags out of there. Makes sense.... Thanks.
You would still use delay_ms(10000); then at that point. Or a timer? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19238
|
|
Posted: Fri May 25, 2018 12:52 am |
|
|
delay_ms.
The whole point is that this then tells you 'for sure' how long the compiler thinks 10 seconds is in instructions. If the figure is wrong, it says the chip isn't running at the speed the compiler expects.....
Now (of course), if this is 'right', we then have the question of why on earth the SPI rate isn't getting to the 243nSec period?..... |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Fri May 25, 2018 10:18 am |
|
|
Ok thought so. I really hope that it's still running at speed.... But it would help in other spots . I think I am getting 970ns which is 4 times slower almost exactly than what you are getting. I will be really mad at myself if this is really the case!
Thanks for all the input.. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Sat May 26, 2018 10:15 am |
|
|
Clock is correct.
Here is what i am using to set up the SPI.
#use spi(MASTER, DO=PIN_B11, MODE=3, BITS=8, stream=NEO_PIX)
I am only getting a 960nS bit width.
I am still going to try switching the pinout so I can use hardware SPI for both. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19238
|
|
Posted: Sat May 26, 2018 11:08 am |
|
|
Er. What pin is being used for the clock?.....
I'd suspect the SPI doesn't like not having a clock pin. After all it is a _synchronous_ bus, and therefore requires a clock. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Sat May 26, 2018 12:02 pm |
|
|
No clock needed for neo pixels. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19238
|
|
Posted: Sat May 26, 2018 1:26 pm |
|
|
I'd suspect this is what is killing the clock rate. The SPI is not designed to support operation without a clock. The software is in a mode it is not written to support. Using the hardware SPI, you will have a clock pin. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat May 26, 2018 1:54 pm |
|
|
He has never said how he's measuring the bit rate. He might be
measuring it incorrectly. He has never posted the code loop that
sends the data. If he posted a complete test program, the issue
would probably be cleared up quickly. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19238
|
|
Posted: Sat May 26, 2018 2:06 pm |
|
|
Very true. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9121 Location: Greensville,Ontario
|
|
Posted: Sat May 26, 2018 3:53 pm |
|
|
the 4x slower is kind of a 'red flag' to me, almost sounds like 'smthing' isn't getting set properly... |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Sat May 26, 2018 6:01 pm |
|
|
Measuring bit rate with a logic analyzer. I actually would be getting 1/2 that as I was using 0xC0 to generate the bit length which is 2 hi's.
This code worked fine on a hardware SPI with baud of 6500000.
Code: |
#use spi(MASTER, DO=PIN_B11, MODE=3, BITS=8, stream=NEO_PIX)
#define one 0xF8
#define zero 0xC0
void WS2812_send_data(unsigned char r, unsigned char g, unsigned char b){
unsigned char s = number_of_bits;
unsigned long value = 0x00000000;
value = (((unsigned long)g << 16) | ((unsigned long)r << 8) | ((unsigned long)b));
while(s > 0)
{
if((value & 0x800000) != LOW){
spi_xfer(NEO_PIX,one);
}
else{
spi_xfer(NEO_PIX,zero);
}
value <<= 1;
s--;
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat May 26, 2018 7:03 pm |
|
|
In a previous thread, you said this:
Quote: | Compiler verison is 5.056. |
Is that still what you're using ? |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Sat May 26, 2018 7:05 pm |
|
|
5.061 now.. |
|
|
|