Asuming that your calculation and formula is ok, you have to round this number (and except certain error), so enter either 11 or 12...YAN-1 said:I see. Thank you. I also have another question. I am using a 20 MHz crystal and I want to set the bit rate of the I2C module to 400 KHz. The value I should place in the SSPADD register should equal:
((Fosc/bit rate)/4) - 1
When calculated, it is 11.5. How do I write this decimal number in the 8-bit register?!
Becuase 20Mhz is a maximum for 16F877, only lower frequency would produce a nice result.eblc1388 said:Or use a crystal of higher or lower frequency which gives you a nice integer for the required data.
20.8 is fine (I though you wanted to overclock it much higher then that), but keep in mind it might interfere with some time critical code...eblc1388 said:You do not need to go very high to get an integer.
Using the same formula, one only need to use a 20.8MHz crystal to get a nice "12" for setting up the register.
Would you consider 20.8MHz pushing the PIC a bit hard? I would say it is fine. However, I would definitely do not advise others to use crystal like 24 or 30MHz.
Jay.slovak said:... but keep in mind it might interfere with some time critical code...
YAN-1 said:I see. Thank you. I also have another question. I am using a 20 MHz crystal and I want to set the bit rate of the I2C module to 400 KHz. The value I should place in the SSPADD register should equal:
((Fosc/bit rate)/4) - 1
When calculated, it is 11.5. How do I write this decimal number in the 8-bit register?!
I was thinking about that too. Maybe if you connect 32768Hz crystal to T1 oscilator... but this is a waste of 2 I/Os and one crystal...eblc1388 said:Jay.slovak said:... but keep in mind it might interfere with some time critical code...
Do you think one can program a PIC to find out what crystal frequency it is operating on and so to adjust the timing of critical code.
So a simple LED blinker would blink with the same period no matter what crystal you give it.
I think it is impossible for a PIC to find that out without external circuitry. But the external circuit can be as simple as a R and C combination on an input pin which can also be used for sensing keypress. The R is already there so you just need an extra small capacitor. I'll work on that.
Oznog said:You can round. Now 3 things here- the PIC is overbuilt for I2C spec and there's probably no problem operating a few percent over 400KHz.
Second, I2C freq is determined by the master so selecting a nonspecified freq- 363.1221324KHz- is no problem at all for any I2C slave.
it depends if you want to proces it or just dispaly it on the other end. For displaying only, send all digits in separate bytes 13.567 => <1> <3> <.> <5> <6> <7>. this is very simple...YAN-1 said:Hmmm.. I see. Thanks everyone. Another question if I may. How can I send numbers like 13.567 or 350.98 or 0.1325 ...etc through either the UART or the I2C or the PSP? Should I send the integer part alone and then the fraction and then join them back at the receiver end?
YAN-1 said:Actually no. I don't need to display it. Just process it. I guess I'll end up sending the integer part and the fraction separately.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?