>-----Original Message----- >From: Vlad [mailto:vlad@DOOM.NET] > >Hello folks > >I'm using a 16f84a to multiplex two common cathode 7-segment >displays connected to PORTB pins 0-6. > >I swith them on and off via NPN transistors connected to pins >PORTA pins 0-1. (after which I need to pause for under 1ms to >get the desired brightness otherwise the transistors switch on >and off too fast and the displays appears dim) This appears >to be working ok and everything runs nice and bright. > >Now, I also have momentary pushbutton switches connected to >PORTA pins 2-3, and I have successfully been able to read the >state of these pins and do something useful on user input. >However, while I am doing this, the displays appear to go dim. >I believe because the transistors are off while im doing stuff >in the check_button routine (see below) > > >the main loop looks this: > >main call display_led > call check_button > goto main > > >The check_button routine looks like this > >check_button btfss PORTA,2 > return > call delay ;deboune (sleep 5ms) > btfss PORTA,2 > return > call do_something ;do_something is just > ;a few clock cycles > return > > >Is my hardware/software design flawed? What can I do to >process user input quickly while preventing any dimming on the >LEDs? This seems like a common thing and have follwed the >wonderful suggestions on this list. I can provide more >information like pictures and complete code, but I just wanted >to feel this out and see if my problem is perhaps simply design related It's not inherrently flawed as such, but it's not the best way to do things. You are apparently waiting around for 1ms each time you update the displays, this time could be much better spent reading the input buttons etc. The neastest way to run a multiplexed display is under a timer interrupt. The CPU overhead is very small, and will leave you with lots of processing time in your main loop to process users inputs etc. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.