DriftZ Posted September 20, 2003 Report Share Posted September 20, 2003 My little MIOS project encountered its next obstacle.The type of display (2-1/2 digit, multiplexed) that I want to use poses a problem, it seems that I need to switch the input very rapidly to get all numbers correct because some of the digit's components share input lines.It's a bit hard to explain, but I'll try with an (fictious)example.I need to send 10001000 to the SR to get the upper half of number '2' lit.I need to send 00010001 to the SR to get the lower half of number '2' lit.If I would send 10011001 to the SR I wouldget a full '2' but also some other stuff lit by 10001001 or other combinations.So the solution would be to switch between the first 2 bytes very quickly.Now in MIOS I cannot find the way to do this kind of loop. I can send the values to the SR, but only the last byte (& so only the lower half of the number) would be on the display. IOW, it does not 'loop'It looks now somewhat like this:USER_SR_Service_Prepare movlw b'01100001' movwf MIOS_PARAMETER1 movlw 0 call MIOS_DOUT_SRSet movlw b'10001110' movwf MIOS_PARAMETER1 movlw 0 call MIOS_DOUT_SRSet returnI tried it also to put it in the USER_SR_Service_Finish & other blocks, but it also didn't work.Is there a good solution to this ? Thanks & greetz !DriftZ Quote Link to comment Share on other sites More sharing options...
TK. Posted September 20, 2003 Report Share Posted September 20, 2003 The solution is to alternate the patterns on every call of USER_SR_Service_Prepare, so that on the first cycle the upper half, and on the second cycle the lower half will be displayed. It's the same method which is used to multiplex the digits (thats the purpose of the counter...), your eyes won't regognize the fast changes. You could use a register named LEDDIGITS_PATTERN_CTR, increment this counter on every cycle (don't take care for overruns) - when bit #0 is set, write the first pattern to the SR, when bit #0 is cleared, write the second pattern.Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
DriftZ Posted September 21, 2003 Author Report Share Posted September 21, 2003 Hi TK, thanks for answering again,The solution is to alternate the patterns on every call of USER_SR_Service_PrepareI made a construction with BTFSC & INCF but still I get the same results.I don't call USER_SR_Service_Prepare from anywhere myself, so is it only called once ? (& it is not looping ?)Then I still would have my original problem, not ?USER_SR_Service_Prepare BTFSC LEDDIGITS_PATTERN_CTR , 0 call ShowUpper ;; (upper half of digit) call ShowLower ;; (lower half of digit) incf LEDDIGITS_PATTERN_CTR returnShowUpper movlw b'01111001' movwf MIOS_PARAMETER1 movlw 0 call MIOS_DOUT_SRSet returnShowLower movlw b'01001111' movwf MIOS_PARAMETER1 movlw 0 call MIOS_DOUT_SRSet returnbest regards Quote Link to comment Share on other sites More sharing options...
TK. Posted September 22, 2003 Report Share Posted September 22, 2003 Hi DriftZ,I don't call USER_SR_Service_Prepare from anywhere myself, so is it only called once ? (& it is not looping ?) Just read the comment above the function:;; -------------------------------------------------------------------------- ;; This function is called by MIOS before the shift register are loaded And shift registers are loaded with the frequency specified by MIOS_SRIO_UpdateFrqSet (you should find this function call in your *_init.inc file - normaly every mS The problem with your code is, that ShowLower is called regardless of LEDDIGITS_PATTERN_CTR, 0 BTFSC LEDDIGITS_PATTERN_CTR , 0 call ShowUpper ;; (upper half of digit) call ShowLower ;; (lower half of digit) incf LEDDIGITS_PATTERN_CTR "btfsc" means: skip next instruction if clear - this means that ShowUpper will be skipped on every second cycle, but ShowLower will be called every time. Improved version: btfsc LEDDIGITS_PATTERN_CTR, 0 call ShowUpper ;; (upper half of digit) btfss LEDDIGITS_PATTERN_CTR, 0 call ShowLower ;; (lower half of digit) incf LEDDIGITS_PATTERN_CTR, F or better readable and understandable: IFSET LEDDIGITS_PATTERN_CTR, 0, call ShowUpper IFCLR LEDDIGITS_PATTERN_CTR, 0, call ShowLower incf LEDDIGITS_PATTERN_CTR, F (IFSET and IFCLR are some macros defined by myself (TK style, see macros.inc), they are using btfsc and btfss)Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
DriftZ Posted September 22, 2003 Author Report Share Posted September 22, 2003 HMPF!... Arghh!... tsk tsk tsk.... <insertbrainlesssmileyhere>Ok.. I never claimed to know anything about ASM... (or clear thinking...)Thanks for helping me out again TK.CheerzUpdate: YEEHAW ;DIt works! Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 12, 2004 Report Share Posted May 12, 2004 Heya DriftZ,I hope I'm not being too rude in asking this of you, but I was hoping that maybe you might be able to post the code for this to the midibox portal perhaps, or maybe some other place?If you'd rather keep your clever tricks a secret, that is understandable though, so no pressure! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.