Well, my DS18B20 program is now running nicely on a PIC18F2620 with decimal values (Anyone interested in reading that thread can find it at http://www.picbasic.co.uk/forum/showthread.php?t=7533).
Anyway, I discovered the fact that I can use MPLab SIM with PBP just 2 days ago and I am ecstatic! I tested some really basic PBP programs with MPLab SIM and was able to input to pins and read registers. Then I tried my DS18B20 program (the source-code is attached at the bottom of this post in text format).
Consider the following lines from my program –
Code:
1 ReadDS18B20:
2 OWOUT Comm_Pin, 1, [$CC, $44] ' Skip ROM search & do temp conversion
3 ReadBusy:
4 OWIN Comm_Pin, 4, [Busy] ' Read busy-bit
5 IF Busy = 0 THEN ReadBusy ' Loop until Busy=1 (Temp conversion complete)
Here, Comm_Pin was set to PortB.4 at the top of the code somewhere (see the complete code). The problem I’m having is that after line 5, it jumps to line 3 and seems to be in an infinite loop. Of course I understand why it happens! It’s because PortB.4 never gets to 1 and this is where I ask for your help.
I have tried to create a stimulus that sets RB4 to 1 at the beginning of the program and keeps it at 1 for good. But when I step through the program, I see RB4 changing periodically between 0 and 1. So, I am not able to simulate a valid bit “1” at RB4. Also, how does anyone go about implementing this:
Code:
OWIN Comm_Pin, 2, [RAWTEMP.LowByte, RAWTEMP.HighByte]
I mean how can I simulate a bitstream arriving at PortB.4? Any help is much appreciated. Thanks.
Bookmarks