Status: New
Owner: robhamerling
Labels: Type-Defect Priority-Medium Component-Device

New issue 169 by robhamerling: Flipping a pin with the 18F PICs
http://code.google.com/p/jallib/issues/detail?id=169

Failing 'alternative' blink-a-led program with an 18F (18F67k90).

This works:

 forever loop
    led = true                      -- on
    _usec_delay(250_000)
    led = false                     -- off
    _usec_delay(250_000)
 end loop

This doesn't work (the LED doesn't blink):

 forever loop
    led = !led                      -- flip
    _usec_delay(250_000)
 end loop

I thought that we agreed on the principle: always read from PORTx and always write to LATx (for PICs which have LATx registers). Therefore in the Jallib device files of the 18F and extended midrange PICs a read from a port or pin always uses the PORTx register, while a write to a port or pin always uses the LATx register (via pseudo variables).

The first case above there are only writes to the pin involved (to LATx register), so there is no read involved.

In the second case however the pin has to be read before it can be flipped properly. Thus the current state of the led-pin is read from the PORT register and the flipped state written to the LAT register. But this seems not to work (in this case).

When writing to a pin it has probably(!) been configured (via TRIS) for output. The question is: must in this case the PORT register be read or the LAT register?



--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to