-- SX-28 - How do I count RTCC's to make a delay of exactly seven microseconds ???
tommy
Posts: 84
- the cross-country advertising truck I drove six months of the year for fourteen years has gone out of business... I can play with my electronic toys full-time, now --- in 2008 (?) - I bought 250 SX-28's to supply me until forever (I'm 74, now).
- today's problem:
-- I cannot get a valid answer from DS1822 1-wire temperature chips, even though I was successful once, two years ago.
-- I am savant (and modest) at assembly language, and have, just this week, read well-written instructions from many 1-wire sources.
-- It MUST be that have the speed incorrect. I have checked and checked everything else for almost ten days...
-- Does anyone remember ??? -- How many RTCC's make up a microsecond ????
--
-- I have been guessing, "four" --- that is: at a Freq of four million, an SX-28 routine (delay) of 28-RTCC's takes seven usecs to execute.
-- but yet I am getting no response from the sensors.
--
DEVICE SX28L,OSC4MHZ,TURBO,STACKX,OPTIONX
IRC_CAL IRC_4MHZ
RESET Start
FREQ 4_000_000
also: MOV !OPTION,#%11011111
-- Thank you
- today's problem:
-- I cannot get a valid answer from DS1822 1-wire temperature chips, even though I was successful once, two years ago.
-- I am savant (and modest) at assembly language, and have, just this week, read well-written instructions from many 1-wire sources.
-- It MUST be that have the speed incorrect. I have checked and checked everything else for almost ten days...
-- Does anyone remember ??? -- How many RTCC's make up a microsecond ????
--
-- I have been guessing, "four" --- that is: at a Freq of four million, an SX-28 routine (delay) of 28-RTCC's takes seven usecs to execute.
-- but yet I am getting no response from the sensors.
--
DEVICE SX28L,OSC4MHZ,TURBO,STACKX,OPTIONX
IRC_CAL IRC_4MHZ
RESET Start
FREQ 4_000_000
also: MOV !OPTION,#%11011111
-- Thank you
Comments
I think your math is fine. With the 4MHz rock, 28 instruction clocks in Turbo mode should take 7 microseconds, whether from the RTCC or in straight code loop. How are you using the RTCC? I think you have the rollover interrupt turned off (in Option).
- I've never yet, in all of my projects wanted a rollover interrupt - I check for things in my main program loops... I don't use the RTCC numbers except in Debug to count program steps when necessary.
- within my loops, a 28-RTCC delay looks like:
DRIVE_1_WIRE_BUS_LOW ;the slave looks for this signal
MOV DX,#03 ;delay 8 µsecs
:LP_001 MOV GSB,GSB
MOV GSB,GSB
DJNZ DX,:LP_001
NOP
RELEASE_1_WIRE_BUS ;let pullup resistor work.
Ref: "It MUST be" statement.
- I'm OCD, I'm INTJ, I'm Hermit-ish (no interruptions) -- I LUV Assembly Language. In the early 90's I wrote whole bowling and inventory programs in MS-DOS Assembly Language using EDLIN ! - (a prehistoric editing program with a killer rename function). --- (I also still use, "PROWRITE" at times)
- The instructions here are so simple -- and so CLEARly stated from THREE different sources -- I have spent two hours a day for a week --- and I can't get a slave-unit to pull the bus to ground for me to see. When I attempt to read either ROM or the SCRATCHPAD I get FF FF FF FF FF FF FF.
- I will spend more time tomorrow going over my, "simple" code.
- I have all the SX manuals - I will go over the RTCC and OPTION functions again -- mostly I want them to do nothing in the background...
- My math is fine, you say. (I had it working two years ago until lightning wiped out the important parts) - I will worry no more and concentrate on finding what ? - a typo, probably.
- Thank you, Tracy for your input.
--- tommy
--- four SX-28 RTCC's does indeed equal one µsec ---
- I sat down last night on my older laptop and rewrote the reset / transmit / read instructions in a straight line (no gosubs) in as simple a form as was possible...
- and behold. -- I got the DS1822 and some of its cousins to spit out the temperature upon command.
- my mistake/omission was probably in the transmit instruction where it called for a 6-µsec delay and some block in my head had previously prevented me from coding a single DX in the loop. (a single DX never loops, but does take up RTCC's in two places just by putting it there)...
---- along for the ride was a mis-read of the flow-chart arrows --- one MUST reset again after a temperature-data-transfer ---- TWO mistakes 'playing tag' at the same time can muddle one's thinking.
- curses on the lightning strike that knocked out half my toys...
-- well, maybe not. My toys will be new and improved (yet again !) --- I long ago used LM34's (?) for temps... then I switched to thermistors in RC circuits... and then, tired of building things that no one else could ever repair, I switched to these 1-wire sensors...
- Thank you, Tracy for the encouragement. I'm just now retired -- (see my very first sentence, above) - so I'll be back on these pages, soon. (Robotic Sun-Flowers will be coming).
tommy
- but I just mentioned Robotic Flowers just above...
-- I would have quit this hobby already had not the 3D-printer come along when it did.
-- when I first saw one actually print something 4 years ago, I bought one within a week.
- the second photo explains it all -- I had bought the motor and the worm gears years before - but never got around to making anything practical -- the white housing in the photo ties them all together and makes real micro-controller machines possible...
- the flowers should be moving (blooming) by Spring.
tommy