PDA

View Full Version : Mibam at 20mhz runs slower than at 4 mhz



Homerclese
- 31st October 2010, 18:25
Hello

I have been playing around with the MIBAM code for quite a while. Sadly, I don't get it. The results that is. Sometimes I will have working code only to come back the next day to find that it morphed into something unrecognizable. I've changed chips, power supplies, re-patched, define bam info... etc....with no change. So I have gone back to square one.

With only 3 outputs running with a 4mhz resonator the fade rate is what I would expect. When I change to a 20 mhz resonator (DEFINE OSC 20 - HS fuse set) the rate slows to a crawl. That is the part I can't understand. Why should the rate slow down with 5 times the clock frequency. I expect to add more outputs which will probably slow things even more. I have code versions that use HSEROUT to output data. That data reads correctly so I know that the clock frequency is right. I see no one else posting this problem so maybe its something about my setup or understanding.

Below is the code. It is basically the example given with the MIBAM code. The J variable does nothing here. I am using 16f628a i/p chips which I believe is a 20 mhz unit (at least that is what the package label said). Any help is greatly appreciated.











;----[ MIBAM Setup ]--------------------------------------------------------

;____[ For 12F/16F only - Interrupt Context save locations]_________________
wsave var byte $20 SYSTEM ' location for W if in bank0
;wsave var byte $70 SYSTEM ' Alternate save location for W
' if using $70, comment out wsave1-3
' --- IF any of these next three lines cause an error ?? -------------------
' Comment them out to fix the problem ----
' -- The chip being used determines which variables are needed -------------
wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
'wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
'---DO NOT change these-----------------------------------------------------
ssave VAR BYTE BANK0 SYSTEM ' location for STATUS register
psave VAR BYTE BANK0 SYSTEM ' location for PCLATH register

BAM_COUNT CON 3 ; How many BAM Pins are used?

INCLUDE "MIBAM.pbp" ; Mirror Image BAM module
'DEFINE BAM_FREQ 500
'DEFINE OSC 20
DEFINE OSC 4
DEFINE BAM_INFO 1


mybyte var byte
K var byte
W var byte
J var byte
N var byte
RayR VAR BYTE
RayC VAR BYTE
RayL VAR BYTE
RayH VAR BYTE

ASM
BAM_LIST macro ; Define PIN's to use for BAM
BAM_PIN (PORTB,1, RayR) ; and the associated Duty variables
BAM_PIN (PORTB,5, RayC)
BAM_PIN (PORTB,3, RayL)
;BAM_PIN (PORTB,6, RayH)
endm
BAM_INIT BAM_LIST ; Initialize the Pins
ENDASM


Speed CON 1 ; Smaller = Faster
Brightness CON 255 ; Max DutyCycle

Main:


For J = 1 to 8
FOR RayR = 0 to Brightness -1 ; Ramp up 1 by 1
PAUSE Speed
NEXT RayR
FOR RayC = 0 to Brightness -1
PAUSE Speed
NEXT RayC
FOR RayL = 0 to Brightness -1
PAUSE Speed
NEXT RayL

FOR RayR = Brightness to 1 STEP -1 ; Ramp down 1 by 1
PAUSE Speed
NEXT RayR
FOR RayC= Brightness to 1 STEP -1
PAUSE Speed
NEXT RayC
FOR RayL = Brightness to 1 STEP -1
PAUSE Speed
NEXT RayL

Next J


GOTO Main

ScaleRobotics
- 31st October 2010, 18:41
The mibam include file reads the osc set in your defines. But if you define your oscillator after the mibam include file, then it assumes your osc is 4 mhz (I think).

Try defining your OSC before your mibam include.