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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/19/05 16:40
Modified:
  03/19/05 16:57

Read: times


 
#90013 - Let me comment....
Responding to: ???'s previous message
Your just now proving to yourself that your "fancy" code is way way to complicated for the simple functions being implemented. You may have the idea that it is 'elegant' but I'll tell you right now that on a '51 such code is hugely inefficient. Especially the use of all the structures and object pointers.

Your 'elegance' is clearly masking your ability to see what is actually going on.

I looked at your code and it is not immediately clear what is wrong but I can say two things. First off the _crol_ function is a ROTATE function and not a SHIFT function. In C code your are far far better off writing something like...
      var |= (1 << bit_numb); 

or
      var &= ~(1 << bit_numb);


Your compiler may be making an assumption about the constant and thinking it is an INT.

Second thing is that right away with problems like this it is essential to look at the underlying assembler code to determine if the code you read in C is what you get in assembler. Handing a C compiler to somebody that cannot look into the assembly language is a very dangerous thing on embedded platforms. This is especially true when embedded code is being developed without the benefit of good development tools and a decent debugging setup. Assumptions of how source code works when every interface is not fully debugged at the module and unit level in the code is what leads to buggy products out in the field. I cannot tell you how many times I seen programmers make stupid mistakes becasue of assumptions or because they skipped unit and module level testing because of not using adequate tools.

This is why I feel it is appropriate to point out that your coding concept is indeed too complicated. There is the additional proviso that I have stated before here on this forum such as at this link:

http://www.8052.com/forum/read.phtml?id=50921

or this link:

http://www.8052.com/forum/read.phtml?id=72432

Michael Karas


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