"Harayasu" <h_onagi@hotmail.com> wrote in message
news:1154726900.283830.162010@i3g2000cwc.googlegroups.com...
> Hello,
>
> On the CPLD which I am using I have a chip attached, via an I2C
> connection. This chip I control via my software driver. I now see
> something strange thing. When I set the clock-line, then the data-line
> goes low in case I do this with the following line of C-code:
>
> port |= MASK_SCL;
>
> But, when I apply the following C-code everyting goes fine:
>
> mirror |= MASK_SCL;
> port = mirror;
>
> Anyone got an idea? Perhaps it has something to do with the
> electronics? The current going down or something like that?
Your problem sounds like your CPLD samples the actual pin value when you
read the port, instead of returning the value in the port driving register.
If this is the case, your 2nd code snippet is a very straight-forward way to
work around the problem.
Remember that even though you write one line of C code: "port |=
MASK_SCL", you are really instructing the hardware to two three things:
1) read the current port value
2) apply a bitwise OR to the value read, and
3) to write the value back to the port.
If during step 1, the device returns the actual state of the pins,
rather than the value in the port register, anything external to the device
which is driving the pin to a logical low state will cause the bit to read
as a 0 instead of the 1 that you had in the register before. The bit
survives the OR done in step #2, and then is written back out as a 0 in step
#3.
Check your datasheet and see if this is the case.
Reply by Jack Klein●August 5, 20062006-08-05
On 4 Aug 2006 14:28:20 -0700, "Harayasu" <h_onagi@hotmail.com> wrote
in comp.arch.embedded:
> Hello,
>
> On the CPLD which I am using I have a chip attached, via an I2C
> connection. This chip I control via my software driver. I now see
> something strange thing. When I set the clock-line, then the data-line
> goes low in case I do this with the following line of C-code:
>
> port |= MASK_SCL;
>
> But, when I apply the following C-code everyting goes fine:
>
> mirror |= MASK_SCL;
> port = mirror;
>
> Anyone got an idea? Perhaps it has something to do with the
> electronics? The current going down or something like that?
>
> Kind regards,
> Harayasu
Reply by Steve at fivetrees●August 4, 20062006-08-04
"Harayasu" <h_onagi@hotmail.com> wrote in message
news:1154726900.283830.162010@i3g2000cwc.googlegroups.com...
> Hello,
>
> On the CPLD which I am using I have a chip attached, via an I2C
> connection. This chip I control via my software driver. I now see
> something strange thing. When I set the clock-line, then the data-line
> goes low in case I do this with the following line of C-code:
>
> port |= MASK_SCL;
>
> But, when I apply the following C-code everyting goes fine:
>
> mirror |= MASK_SCL;
> port = mirror;
>
> Anyone got an idea? Perhaps it has something to do with the
> electronics? The current going down or something like that?
Perhaps the port is write-only. Or the macro used to address the port can't
deal with read-modify-write.
Steve
http://www.fivetrees.com
Reply by Harayasu●August 4, 20062006-08-04
Hello,
On the CPLD which I am using I have a chip attached, via an I2C
connection. This chip I control via my software driver. I now see
something strange thing. When I set the clock-line, then the data-line
goes low in case I do this with the following line of C-code:
port |= MASK_SCL;
But, when I apply the following C-code everyting goes fine:
mirror |= MASK_SCL;
port = mirror;
Anyone got an idea? Perhaps it has something to do with the
electronics? The current going down or something like that?
Kind regards,
Harayasu