HPWM Declare problem. Any ideas ?


+ Reply to Thread
Results 1 to 9 of 9

Thread: HPWM Declare problem. Any ideas ?3953 days old

  1. #1
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default HPWM Declare problem. Any ideas ?

    Hello all. this is a continuation of my problems from yesterday in debugging a piece of code. Today however, I have not had a liquid lunch, so my head is clearer.

    I need to use both hpwm pins on aproject to drive an analogue resolver for a compass unit. Anyways, heres the problem..

    On the 18F452 there are 2 pins for CCP2 Portc.1 and Portb.3

    Using a proton development board, or indeed the Virtual develeopment board in isis, PortC.1 is used for the GLCD RSPIN. so is not available if the lcd is being used.

    I therefore used..

    Declare CCP1_PIN PORTC.2
    Declare CCP2_PIN PORTB.3

    in my program. The program compiles fine but HPWM on device 2 (CCP2) is still on PORTC.1 !
    This will then cause bus clashes with the GLCD and corrupt the display, as well as no hpwm on ccp2..(If I Un Rem the print routines)

    So the problem is for some reason I cannot change to the alternate CCP2 pin.

    Any ideas please..
    Heres my test code, I have remmed out the print routines and the hpwm is working on portc.1 and portc.2, not as the declare for ccp2 = portb.3
    I hope that makes sense....
    Joe.

    Device = 18F452
    XTAL = 20
    Include "proton18_g20joe.int" ' Purely graphic lcd only

    'declare CCP1_PIN PORTC.2
    'declare CCP2_PIN PORTc.1
    TRISB=0
    Declare CCP1_PIN PORTC.2
    Declare CCP2_PIN PORTB.3 ' alternate CCP2 pin on 18F452

    Dim Duty_Cycle_1 As Byte
    Dim Duty_Cycle_2 As Byte
    Dim Frequency As Word

    Frequency = 2000 '2kHz

    DelayMS 500
    Cls
    'hpwm channel, duty,frequency

    start:
    Duty_Cycle_2 = 255
    For Duty_Cycle_1 = 0 To 254
    DelayMS 100
    'Print At 0,0, Dec, Duty_Cycle_1 ," "
    'Print At 1,0, Dec, Duty_Cycle_2 ," "
    GoSub Set_HPWM
    Dec Duty_Cycle_2
    Next Duty_Cycle_1

    Duty_Cycle_2=0
    For Duty_Cycle_1 = 255 To 0 Step -1
    DelayMS 100
    'Print At 0,0, Dec, Duty_Cycle_1 ," "
    'Print At 1,0, Dec, Duty_Cycle_2 ," "
    GoSub Set_HPWM
    Inc Duty_Cycle_2
    Next Duty_Cycle_1
    GoTo start
    Set_HPWM:
    HPWM 1,Duty_Cycle_1,Frequency
    HPWM 2,Duty_Cycle_2,Frequency
    Return
    Stop
    Include "font.inc"
    to clarify.. The program above as purely as sample of the 2 hpwm outputs with different duty cycles will alternately brighten and dim 2 leds connected to the HPWM output pins, thats all working fine, but on portc.1 and portc.2... it is not altering ccp2 to Portb.3
    Joe.

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default

    As an update, I think there may be a register setting to adjust the ccp2 pin to the alternate, possibly ccp2con, I am struggling to find the info in the datasheet for the settings though, will dig deeper.. edit, dug deeper and no hint to the functions of the bits in ccp2con... yet..

    If, and its looks likely it IS a register setting, and I change it directly in code, what would the declare be then for the CCP2PIN for HPWM on device 2?..

    Joe.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default

    Hi Capt,

    I think you have to set CCP2mux to ON in the fuse configurator


    regards
    John

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default

    Thanks John, I never thought about fuses !!!.. excellent.. will go and dig deeper again...
    Need to get the programmer out as I am using a bootloader at the mo..

    I really appreciate you input.. Yes, fuses... of course !.. been using the bootloaders for so long now (switching to icsp on ALL projects in the next few weeks) that I never considered them, was looking at registers..

    you da man !..

    Thanks for the time to consider this, it has had me looking for gremlins in the bilges lol...

    Joe.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default

    he he Joe...See if it works first!

    I'm at the lower end of the Proton smart guy list, and take more from here then I give sadly. So its nice to help where I can.

    John

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default Sorted, thanks John !

    John,
    Thanks ever so much for pointing me in the correct direction.
    YES, it was the fuse settings for the bootloader..
    The interesting thing is I need to set CCP2MUX to DISABLED for it to work..

    It WAS enabled.
    Anyway, all hunky dory now.

    As for the CCP2PIN declares, it doesnt matter..

    if you use
    Declare CCP2_PIN PORTC.1
    or
    Declare CCP2_PIN PORTB.3

    Once the mux is disabled by the fuse config, it works on PORTB.3 whatever you do..

    as an aside,
    There is an interesting output on Timer2 with a postscaler.. not used for PWM in hardware. that cuases an interrupt.. this could, with a few lines of code and possibly another unused timer be used to generate another semi hardware pwm output, or at least an interrupt driven pwm on the same frequency as the other two hpwms.. you could also use a divide by 1 to 16 on this postscaler to create LF HPWM...
    I dont need this for this project at the mo, but will experiment. I am using the hpwm outputs to drive two rail to rail opamps in voltage follower with a times 2 gain to give a 10v variable outputs, well two 10v variable outputs to drive a sort of resolver used in an old MARINER wind direction and compass repeater instrument..
    Ultimately it will be all non proton HPWM as its limited to byte size for the duty, I really would like to see full 10 bits enabled in proton for ease of use as I need 10 bit res for this project... (ie for 1 degree of res on a 360 degree scale I need greater than 256.. so 10 bit will be the end result.. just in the process of writing the inc for the 10 bit routine with a simple call.. I needed to make sure it worked first..
    With your excellent help, it does.

    Thanks a million.
    Joe.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by pic-ignorant View Post
    he he Joe...See if it works first!

    I'm at the lower end of the Proton smart guy list, and take more from here then I give sadly. So its nice to help where I can.

    John
    DONT EVER underestimate your skills..

    It is so easy in this game to not see the wood for the trees.....
    I have been buggering about with this for two days,, !!

    Thought I had some problem on simple integer math... (Its easy to convince oneself its the compiler at fault. we, of course , write perfect code all the time lol....

    Somtimes it just takes another persons input to get around a seemingly unsurmountable issue.

    I try to be Mr Spock and use logic, but I must have missed out on the Vulcan training rituals in early life... hee hee...

    Again, thanks.. you ARE da man.. !.

    there was a reference in the datasheet to ccp2 mux, but no mention of fuses / config, that I could find.

    Your post was like a Pan Galactic Gargle Blaster .. ie... having my brains smashed out by a slice of lemon wrapped around a large gold brick. (Dougie Adams RIP ! )

    It stimulated the brain to look for other things where I had drawn a blank.

    Kudos Mi Amigo !!!

    Joe.

    And again, thanks ..

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Fanatical Contributor fanie's Avatar
    Join Date
    Oct 2005
    Posts
    7,970
    Thumbs Up
    Received: 29
    Given: 14
    Total Downloaded
    356.97 MB

    0 Not allowed!

    Default

    I'm at the lower end of the Proton smart guy list
    Yes good grief John. If you're looking for sympathy get a dog instead

    You have been doing pretty ok in my book too. Some of us just have bigger mouths and have programmed a couple of pics more than you did - most of the time because we don't have any other choice but to stay alive with it

    The difference between ok and very good usually is just a couple of clicks...
    Fanie

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default

    Quote Originally Posted by fanie View Post
    Yes good grief John. If you're looking for sympathy get a dog instead

    You have been doing pretty ok in my book too. Some of us just have bigger mouths and have programmed a couple of pics more than you did - most of the time because we don't have any other choice but to stay alive with it

    The difference between ok and very good usually is just a couple of clicks...
    I just tell it as it is Fanie

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Problem with Declare Bootloader = On
      By AlbertoFS in forum Proton Plus Compiler v3
      Replies: 4
      Last Post: 14th November 2016, 21:57
    2. [SOLVED !] HPWM declare problem PIC16F1825
      By RayEllam in forum Proton Plus Compiler v3
      Replies: 1
      Last Post: 25th November 2015, 08:33
    3. [SOLVED !] Problem with floating point declare
      By sdemonte in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 19th March 2014, 10:17
    4. [SOLVED !] problem with hpwm
      By Dphil7532 in forum Proton Plus Compiler v3
      Replies: 10
      Last Post: 1st March 2007, 22:51
    5. Declare problem in array
      By Roshan in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 19th January 2006, 14:50

    Members who have read this thread since 27th November 2019, 21:37 : 0

    Actions :  (Set Date)  (Clear Date)

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

    Tags for this Thread

    Posting Permissions

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