I guess I picked a difficult one to simulate.
The problem is that OWIN and OWOUT are both toggling the TRISB.4 bit (changing this pin between Input and Output) and therefore a constant "1" for PortB.4 (The DS18B20's DQ pin) did not work for me. What I did was create an asynchronous event for RB4 (set RB to High) and whenever my TRISB was 00010000 (RB4 is input), I just hit this asynchronous event that set RB to 1. If I was careful and hit this event at the right time, the "Busy" variable would finally be 1 and thus the program would finally get out of the infinite loop.
I didn't play with the PORT/Register injection. I guess the easiest thing would be to define a value for RAWTEMP at the beginning of the program (just for debugging process) and see if my temperature conversion subroutines worked correctly (and they did). I wanted to check the negative temperature read and conversion routine in particular since I was inside my house and the outside temperature was not below zero, or I didn't feel like pouring liquid nitrogen on the sensor (not that I had any liquid nitrogen in my house).
If anyone else wants to take a shot at simulating the One-Wire commands correctly (from a timing point of view), good luck.
Bookmarks