Problem With Code Terry Can you Help
I was working with Jonny Mac on some code He wrote and I am have a problem getting it to work correctly. I am attaching the code.
Everything runs fine until I Change the pins...
The Unaltered Code block...
And now my changes to accomidate a circuit board I designed.
We can't figure out why when M2InA and M2InB are changed to port D pins the program does not transmit serial properly.
Can you help?
Everything runs fine until I Change the pins...
The Unaltered Code block...
Sio PIN RD.7 INPUT TTL ' I/O to host (10K pull-up) M2Pwm PIN RC.2 OUTPUT M2InA PIN RC.1 OUTPUT M2InB PIN RC.0 OUTPUT
And now my changes to accomidate a circuit board I designed.
Sio PIN RD.7 INPUT TTL ' I/O to host (10K pull-up) M2Pwm PIN RC.2 OUTPUT M2InA PIN RD.1 OUTPUT M2InB PIN RD.0 OUTPUT
We can't figure out why when M2InA and M2InB are changed to port D pins the program does not transmit serial properly.
Transmit: ASM MOV FSR, #serial ' (2) TEST txCount ' (1) transmitting now? JZ TX_Done ' (2/4) if txCount = 0, no DEC txDivide ' (1) update bit timer JNZ TX_Done ' (2/4) time for new bit? MOV txDivide, #Baud1x0 ' (2) yes, reload timer STC ' (1) set for stop bit RR txHi ' (1) rotate TX buf RR txLo ' (1) DEC txCount ' (1) update the bit count MOV W, #$0F ' (1) read TRIS_A MOV M, W ' (1) MOV !RD, W ' (1) MOV tmpTris, W ' (1) copy to tmpTris MOVB tmpTris.7, txLo.6 ' (4) new bit to tris MOV W, #$1F ' (1) update TRIS_A MOV M, W ' (1) MOV !RD, tmpTris ' (1) TX_Done: ENDASM
Can you help?
Comments
I can vouch for this the program runs fine until you try to change the status of the RD.1 and RD.0 bits, and this makes absolutely no sense at all.
· PLP_C = %0000_0111
· PLP_D = %1000_0000
but port C and port D have different pullup settings on pins 0 and 1.
regards peter
Post Edited (Peter Verkaik) : 5/28/2009 7:09:54 AM GMT
Try adding a "CLRB Sio" after the "MOV !RD,tmpTris" in the transmit routine.
Try this program below to show the cause of this problem.
Bean.
P.S. "MOV !RD,tmpTris" is a 2 cycle instruction "MOV W,tmpTris", "MOV !RD,W"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
Post Edited (Bean (Hitt Consulting)) : 5/28/2009 12:31:29 PM GMT
Eric, the version attached uses your original connections and I've verified that the code is now talking back (to a Stamp).
Post Edited (JonnyMac) : 5/28/2009 5:03:18 PM GMT
Thanks.. for picking though out.
Jon,
Thanks for all of your help and your code. I'll be playing with this when I get home tonight.
Best Regards to Both,
Eric