Re: (no subject)
Samuel Tardieu <[email protected]> 16 Mar 2005 19:19:36 +0100
| Newsgroups | gmane.comp.lang.forth.picforth |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Polly" == bitwLister <[email protected]> writes: Polly> I can't make the 'toggle' work .. the port in question is Polly> all outputs and picforth seems to compile an xorwf instruction Polly> .. Isn't there something about a read-modify-write not working Polly> in this case ?? It depends. If your PIC is authoritative in the output and that the lines switches from low to high and vice-versa in less than one PIC clock, then you are safe. And this covers most cases. Otherwise, you can use toggle on this port as PicForth as no way to know what you put in the port last. You have to write your own toggle, for example, if this is on port C that you're writing, you could have: variable latc :: report-latch latc @ portc ! ; :: latc-or! latc or! report-latch ; :: latc-/and! latc /and! report-latch ; :: latc-xor! latc xor! report-latch ; macro : >lat 1 swap lshift ; : latc-bit-set >lat latc-or! ; : latc-bit-clr >lat latc-/and! ; : latc-bit-toggle >lat latc-xor! ; target Then you will be able to use a safe version of the port with: : foo 2 latc-bit-toggle ; / Toggle pin C2 Which expands to: ; name: foo ; max return-stack depth: 0 0x0016 3004 movlw 0x04 0x0017 2812 goto 0x012 ; latc-xor! Sam -- Samuel Tardieu -- [email protected] -- http://www.rfc1149.net/sam