pwm no workee


Closed Thread
Results 1 to 4 of 4

Thread: pwm no workee

  1. #1
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108

    Default pwm no workee

    I had pwm working fine with my LabX1 and PIC 16F887. In my circuit, the 16F88 does not work. I have a scope on the output and I see nothing. Here's relevant code: (I took out some code to do with other operations to make it easier to read). By the time the program hits the HPWM command, I should see wigglies on the scope. I see nothing. I started ONLY with that command (and TRISB) and added the other config fuses and defines later in attempt to make it work. BTW, the other part of the program (timer, interrupts, A/D for voltage measurement) WORKS, so I know the MCU and oscillator and stuff is okay. I want to use RB3 (CCP1). I've reduced frequency to 8000 Hz for testing.
    Any ideas?

    #config
    __config _CONFIG1, _LVP_OFF & _CP_OFF &_MCLR_ON & _PWRTE_OFF & _WDT_OFF & _CCP1_RB3 & _INTRC_IO & _CCPMX_RB3

    #endconfig
    duty var byte
    freq var word

    'Initialize
    OSCCON= %01110000 'Internal oscillator, 8 MHz
    TRISA= %11111111 'Set PORTA <D7-D0> to input
    TrisB= %00000000 'set portb <D7-D0> to output
    ANSEL= %00000011 'set portA analog on PortA <0-1>
    ADCON0= %01001111 'enable ADC channel 0 and 1
    ADCON1= %10000000 'right justify result
    temp=0 'variable for Button command

    Pause 100 'Wait for LCD to start up
    define ccp1_reg PortB
    define ccp1_bit 1
    duty=127 '50% duty cycle
    freq=8000 'test frequency
    hpwm 1,duty,freq 'Start PWM 38000 khz signal from RB3 of 16F88

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: pwm no workee

    Lower case defines?

    Robert

  3. #3
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: pwm no workee

    My PBP3.0 client (MicroCode Studio) automatically turns the defines into lower case.

    In any case (no pun intended), I have a number of other defines used for A/D conversion and LCD prep that work fine.

    Since I posted the code above, I changed "duty" and "Freq" from Var to Con (constant), not that it made any difference.

    I'm pulling the chip and will see if it's a hardware problem. I could also check if RB0 works instead of RB3, because I cannot see where there's a problem in software.

  4. #4
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: pwm no workee

    Believe it or not, I replaced the chip and now the pwm is working. (see attached screenshot of scope trace). Yet, all the other sections were working fine, A/D conversion, LCD display, interrupts and timer.
    Name:  Screenshot - 04_06_2013 , 10_38_05 AM.jpg
Views: 264
Size:  67.2 KB

    Now, I will go back and make it not work to see what codes I don't need and/or do need.

    I was going to say that I "wasted" a lot of time trying to make the software work, but in a way I didn't waste anything because I was forced to read the data sheet with a little more care, and investigate other programs for solutions.

Similar Threads

  1. Replies: 1
    Last Post: - 4th March 2013, 21:57
  2. Pwm
    By xobx in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th February 2008, 06:33
  3. pwm
    By Md.Shah in forum mel PIC BASIC
    Replies: 1
    Last Post: - 4th October 2006, 05:07
  4. Pwm
    By Armando Herjim in forum General
    Replies: 2
    Last Post: - 10th September 2006, 09:05
  5. pwm
    By sawyer in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th July 2006, 04:12

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