Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/20/05 22:37
Modified:
  03/20/05 22:40

Read: times


 
#90059 - Damned, damned, damned...
Responding to: ???'s previous message
All,

After I shot myself 5 times in the head (and one time in the foot), I still found the energy to write a last message regarding this subject...

Erik, you were (once again) right from the beginning! You must be one of the 'white ravens' out there (at least, in the 8051 area...). ;-)

Let me tell what the problem was:

As told and said and shown in the code, I wanted to use pin0 as input and all the rest as output.
I used pin6 to control a LED.

Now what happened was: When I pressed the button down, the level of pin0 was '0'. So, when I read the byte, I got the value 0x40 back.
Due to that, I wanted to write a '0' to pin6 too, to activate the LED.
So, I had to write a complete byte back to the IO expander, with value 0x00 in this case.

BUT!!! Since pin0 was an input, I was not allowed to write '0' to pin0. I was 200% sure that I prevented the pins defined as input from being written with '0', because I was using a mask that defined the pins defined as inputs.

However, I was storing the mask inside a variable in my 8574 structure that was at last not holding the correct mask anymore.
So, when I read 0x40 because the key was pressed ('0' at input of pin0), I stored 0x40 in the buffer => gone mask!!!.

Solution: added an extra field to the struct that only saveguards a mask defining the input pins of that device.
Now, when I'm finished with the shifting, the bitwise "OR"-ing and the inversion, I bitwise "OR" again the result with the mask (this one never changes anymore).
Because of that, the bits representing the inputs are set to '1' again.

Sorry guys for:

  • bothering you with such a stupid mistake
  • taking your valuable time
  • annoying you with a problem that wasn't a problem
  • keeping you away from your family lives while reading this (in the mean time) long thread
  • making some people 'angry' because of my not-so-optimal code

...and sorry to my cat Spooky for chasing her off of my keyboard this morning...
Here's a picture of her:



Now I can continue to drop dead... RIP... Sih!

Best rgds,

--Geert

List of 77 messages in thread
TopicAuthorDate
Problems with PCF8574 input            01/01/70 00:00      
   best guess            01/01/70 00:00      
      To Erik            01/01/70 00:00      
         So....            01/01/70 00:00      
            To Jez Smith            01/01/70 00:00      
         show the code            01/01/70 00:00      
            To Oleg            01/01/70 00:00      
               How to post code            01/01/70 00:00      
                  To Andy            01/01/70 00:00      
   hmmmmmm            01/01/70 00:00      
      To Jez            01/01/70 00:00      
   RTFDS - using 8574 IO as inputs            01/01/70 00:00      
      To J. Guy            01/01/70 00:00      
         When is pin written ?            01/01/70 00:00      
            My datasheet tells something different..            01/01/70 00:00      
               To Kai            01/01/70 00:00      
                  cutting through the fog            01/01/70 00:00      
            To J. Guy            01/01/70 00:00      
   Where is the difference between...            01/01/70 00:00      
      To Kai            01/01/70 00:00      
         Re:Problems with PCF8574 input            01/01/70 00:00      
         Test it without having any communication            01/01/70 00:00      
            To Kai            01/01/70 00:00      
   Maybe good guess!            01/01/70 00:00      
      To Medhi            01/01/70 00:00      
      Switch terminology            01/01/70 00:00      
         Thanks!            01/01/70 00:00      
            Coonfoosed yeeet            01/01/70 00:00      
               Contact arrangement - nothing else            01/01/70 00:00      
   PCF8574            01/01/70 00:00      
      To Ben            01/01/70 00:00      
   I have used the bugger often            01/01/70 00:00      
      To Erik            01/01/70 00:00      
         helloooooooooo !!            01/01/70 00:00      
            To Erik            01/01/70 00:00      
         Wager...            01/01/70 00:00      
            To Grant            01/01/70 00:00      
      The code...            01/01/70 00:00      
         Thats told 'em :-)            01/01/70 00:00      
            Frightend... ;-)            01/01/70 00:00      
         Formatting            01/01/70 00:00      
            Format flavours.            01/01/70 00:00      
   Insanity            01/01/70 00:00      
      Malaysian Grand Prix...            01/01/70 00:00      
   Some update!!!            01/01/70 00:00      
      Let me comment....            01/01/70 00:00      
         "fancy" code            01/01/70 00:00      
            I'll Suggest...            01/01/70 00:00      
               Pointers and structures            01/01/70 00:00      
         C assumes int            01/01/70 00:00      
            Followed the advice of Michael Karas...            01/01/70 00:00      
               Why not assembly using?            01/01/70 00:00      
                  Assembler code            01/01/70 00:00      
            Well...            01/01/70 00:00      
               int            01/01/70 00:00      
                  Check Maxint ?            01/01/70 00:00      
                     Maxint            01/01/70 00:00      
                  Murdered quote            01/01/70 00:00      
   I2C code            01/01/70 00:00      
      Keil webpage            01/01/70 00:00      
         i2c simulator            01/01/70 00:00      
            Me to blame?            01/01/70 00:00      
               not blaming you!            01/01/70 00:00      
                  Michael B. made a very usefull tool!            01/01/70 00:00      
         hello            01/01/70 00:00      
            Not aware?            01/01/70 00:00      
               thank u            01/01/70 00:00      
                  Name confusion...            01/01/70 00:00      
               hi            01/01/70 00:00      
   Damned, damned, damned...            01/01/70 00:00      
      Ha, ha, ha, ha, ha ....            01/01/70 00:00      
      Calico            01/01/70 00:00      
         Pls. do so!            01/01/70 00:00      
      Keyboard Calico            01/01/70 00:00      
         Christmas            01/01/70 00:00      
            Maybe it was ....            01/01/70 00:00      
            Christmas Presents            01/01/70 00:00      

Back to Subject List