bad expression error, linking addresses incorrectly.


Results 1 to 6 of 6

Threaded View

  1. #4
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    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:

    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.
    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...?

    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.
    Last edited by robertpeach; - 25th August 2009 at 14:45.

Similar Threads

  1. PBP bad expression
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th October 2009, 01:01

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts