thanks for you reply
i am using 20Mhz crystal if i define osc 20 then i get garbage from serout so i changed it to 48
is it wrong?
thanks for you reply
i am using 20Mhz crystal if i define osc 20 then i get garbage from serout so i changed it to 48
is it wrong?
Is the posted code all of it? Did you do any configuring? Not sure you need to, just trying to see where to start looking in the datasheet to be able to answer. In the mean time, here is a quick easy test for if the speed is correct:
Of course you still need all setup stuff like define osc and such, but if the speed is correct you should get a blink at 60 hz.Code:main: toggle "some output with an LED connected" pause 500 goto main
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
when i put the above code (@ osc 48) led remained on and never turned off, so i modified it and led blinks at 1hz
when i changed osc to 20 i got led to blink at 2hz..Code:test: high porta.0 pause 250 low porta.0 pause 250 goto test
Ok, first my apoligies, you should have gotton 1 hz with the code I posted. NOT 60 Hz. if the LED never turned off, well that is confusing. Maybe a typo somewhere?
On to more important stuff. with your code as posted (pause 250) you should get 2 hz. Is that what you are getting? pause 250 equals 2 Hz with OSC 20? If this is so, then I think you need to have OSC 20 as your define. Heres why I know:
pause uses OSC define to generate delays in software based on the OSC value. So when OSC matches actual pic speed the pauses will be the correct amount of time. 250 mSec on then 250 mSec of is 2 Hz.
So assuming make sure your DEFINE OSC is correct. Of course that doesn't address the fact that you say you get junk from serout when OSC is 20.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
sorry i messed up the test results, this is the result i got, tested it twice
test program
test:
high porta.0
pause 500
low porta.0
pause 500
goto test
result at osc 48
led on off duration is exactly 1 second
result at osc 20
led on off duration is twice
so i think define osc is correct.
i found this code(in document section) from sparkfun:http://www.sparkfun.com/products/9814
it is for adxl345 and uses spi but its in c and for atmega..
Well I am sorry it wasn't as simple as the clock being wrong, But now you know how to test it. I actually do this on all my programs before going any further just to verify the clock/osc and me are all at the same speed.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
The SHIFTOUT command sends 8-bits unless otherwise specified.
To send a 16-bit constant, you'll need to specify the number of bits.
shiftout data_out, CLOCK, 2, [%0011000100100000\16]
DT
Bookmarks