generate PWM from PIC16F1934

Discussion in 'Embedded Systems and Microcontrollers' started by divakar, May 15, 2010.

  1. divakar

    Thread Starter New Member

    May 15, 2010
    2
    0
    Hai,

    I have generated PWM from couple of other PIC ICs. This is my first try with 16F1934 and am unable to generate simple PWM pulse. I wrote code in assembly language at MPLAB v8.45 and use its 'simulator logic analyzer' to derive the pulse. I have listed the steps i have taken in the writing the code. CCP4 module is used and RD1 channel is selected at simulator. still i get a blank line. I can give the code also if needed...


    1. disabling the CCP4 pin by setting TRISD 1st bit (bsf TRISD,1). Bank 1 is selected for this operation (by writing h'01' at BSR).
    2. timer4 is selected by writing h'40' value to CCPTMRS0. Bank 5 is selected for this operation
    3. h'ff' value is written at PR2. Bank 8 is selected for this operation.
    4. b'00101100' value is written to CCP4CON and b'10101010' is written to CCPR4L. Bank 6 is selected for this operation.
    5. Timer4 interrupt flag is cleared (operation done at Bank 0)
    6. h'06' value is written to T4CON (operation done at bank 8), to set prescale and to turn it on.
    7. check if the timer 4 interrupt flag is set. If set, clear it (operation done at bank 0)
    8. clear TRISD,1 (done at bank 1)


    Divakar Raj. R
     
  2. upand_at_them

    Active Member

    May 15, 2010
    246
    29
    Is there anything for the PIC to do after step 8?
     
  3. divakar

    Thread Starter New Member

    May 15, 2010
    2
    0
    In this current attempt, PIC has got nothing to do after step 8... I have got more to add to it, but i want to check PWM operation before I develop project. My final attempt is to design a closed loop control system for electric machines.
     
Loading...