ok doesnt look like anyone could help me before.. but i have a new question regarding the 2431.
ive been trying to get a pwm output using the following code:
last night this code worked for me, and i was getting a good pwm output. however today it wont work, ive checked my wiring is correct, by testing using multimeter and with other programs. however when i run the current program i get a pulse width output for about 10 seconds before it dies, i also havee an led attached to one of the pwm outputs which also fades out at the same time to check. ive fiddled alot with the fault byte to check it wasnt that. but i cant think of what else could be causing this problem? also for the 10 seconds it does appear... the 0 points on my pwm wave are actually slanted upwards slightly...?Duty Var Word
PORTB = 0 ' clear port latch
TRISB = %11000000 ' PWM0,1,2,3,4,5 outputs
TRISC = 2 ' RC1 = FLTA input (ground RC1 to halt PWM)
' RC1 should be pulled high for normal PWM operation
' when fault A is enabled.
' PCPWM init
DTCON = %00000101 ' ~500nS dead-time (for complementary outputs only)
PTCON0 = %00000000 ' 1:1 postscale, Fosc/4 1:1 prescale, free running mode
' PTCON0 = %00000100 would give 19.45kHz/4
PTPERL = 0 '
PTPERH = 1 ' PTPER = $0100 or 256d for ~19.45kHz
' PWM4,5 independent, PWM0,1,2,3 complementary
PWMCON0 = %01010100 ' PWM[5:0] outputs enabled
PWMCON1 = 1 ' updates enabled, overrides sync w/timebase
PTCON1 = %10000000 ' PWM time base is ON, counts up
FLTCONFIG = %00000011 ' enable fault A, cycle-by-cycle mode
Duty = 800 ' ~50%
PDC2L = Duty.LowByte ' maintain a fixed 50% duty cycle on PWM4,5
PDC2H = Duty.HighByte ' independent PWM outputs.
additionally since i havnt purchased a crystal yet, i thought id use the internal oscilattor INTIO1. this runs at a maximum of 8mhz. maybe this is causing the problem? ive tried to adjust my prescalers inrespect to this, however i still get the problems.
Bookmarks