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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/12/05 09:25
Read: times


 
#100927 - Week puzzle IV
This has been posted by Erik Malund a couple of weeks ago but went unnoticed, while I think is worth discussing as part of "puzzle of the week" series. - JW.

Erik Malund in a recent post said:

Port 1 is used as follows:
  • bits 4-7 are set individually both in ISRs and in the main some are used as inputs.
  • bits 0-3 hold pin_value that is set in an ISR.
  • pin_value does never have bits 4-7 set

1) If you write P1 in an ISR as follows
in asm:
mov a,P1
anl a,#0f0h
orl a,pin_value
mov P1,a
in C:
P1 = ((P1 & 0xf0) | pin_value);
what will go wrong? - something in the asm. something may in the C

2) how will you do this so it works - there are, at least, two ways, show both.


List of 23 messages in thread
TopicAuthorDate
Week puzzle IV            01/01/70 00:00      
   In my opinion            01/01/70 00:00      
      no            01/01/70 00:00      
         Bufff!! then TRB            01/01/70 00:00      
            Me and my shadow, walking down the aven            01/01/70 00:00      
               You & your shadow            01/01/70 00:00      
                  http://www.coleporter.org/            01/01/70 00:00      
                     it's a hint            01/01/70 00:00      
   Well            01/01/70 00:00      
      you got it            01/01/70 00:00      
         Just OR with ones            01/01/70 00:00      
            how?            01/01/70 00:00      
   a simple solution:            01/01/70 00:00      
      not atomic            01/01/70 00:00      
         atomic not possible in general !            01/01/70 00:00      
   My solution!            01/01/70 00:00      
      Wrong            01/01/70 00:00      
      not atomic            01/01/70 00:00      
         Ok, here is the shadow            01/01/70 00:00      
            only four bits            01/01/70 00:00      
               2 Hints!            01/01/70 00:00      
                  Oh boy, do you need some bible time            01/01/70 00:00      
                  re: 2 Hints!            01/01/70 00:00      

Back to Subject List