PBP3/MPLABX - PIC18F46Q10: The sound function.


+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10

    Default PBP3/MPLABX - PIC18F46Q10: The sound function.

    Hi all, I am a 20+ years user of PBP. I am porting an existing product from a PIC18F4252 (MPLAB8) to PIC18F46Q10 (MPLABX) for now all look ok except the sound function does not work. If I high and low my Piezo pin I have sound. For a reason I don't understand there nothing using the normal function. Any idea ?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Many, but all guesses...

    Maybe you post the complete code?

    Ioannis

  3. #3
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    I will take your guesses, this won't help:

    sound piezo,[124,10]

    Thanks

  4. #4
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Hi Ioannis, can tell me if I should just go back from MPLABX 5.35 to a working Pic on MPLAB8 ? Maybe there is other stuff not working normally.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    You should use 5.35 version. This is the latest PBP supports and needs for the relatively new chips.

    Going back will not help.

    New chips have lots of functions and you need to do your homework setting up the ports correctly.

    If the program worked OK on an older chip it will work on the new one, as long as you set it up correctly.

    Since you do not post your code there is no more we can say about it.

    Use MCC to set up the chip you are using.

    Ioannis

  6. #6
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    So I have checked all registers concerning the Ports and Timers source clocks. Add them to my program.
    Here is the setup:


    DEFINE OSC 4
    DEFINE CHAR_PACING 2000
    INCLUDE "modedefs.bas"


    #CONFIG
    CONFIG FEXTOSC = HS ;HS (crystal oscillator) above 8 MHz; PFM set to high power
    CONFIG RSTOSC = EXTOSC ;EXTOSC operating per FEXTOSC bits (device manufacturing default)
    CONFIG CLKOUTEN = OFF ;CLKOUT function is disabled
    CONFIG CSWEN = ON ;Writing to NOSC and NDIV is allowed
    CONFIG FCMEN = ON ;Fail-Safe Clock Monitor enabled
    CONFIG MCLRE = EXTMCLR ;MCLR pin (RE3) is MCLR
    CONFIG PWRTE = ON ;Power up timer enabled
    CONFIG LPBOREN = OFF ;Low power BOR is disabled
    CONFIG BOREN = ON ;Brown-out Reset enabled according to SBOREN
    CONFIG BORV = VBOR_245 ;Brown-out Reset Voltage (VBOR) set to 2.45V
    CONFIG ZCD = OFF ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
    CONFIG PPS1WAY = OFF ;PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence)
    CONFIG STVREN = ON ;Stack full/underflow will cause Reset
    CONFIG XINST = OFF ;Extended Instruction Set and Indexed Addressing Mode disabled
    CONFIG WDTCPS = WDTCPS_31 ;Divider ratio 1:65536; software control of WDTPS
    CONFIG WDTE = SWDTEN ;WDT enabled/disabled by SWDTEN bit
    CONFIG WDTCWS = WDTCWS_7 ;window always open (100%); software control; keyed access not required
    CONFIG WDTCCS = SC ;Software Control
    CONFIG WRT0 = OFF ;Block 0 (000800-001FFFh) not write-protected
    CONFIG WRT1 = OFF ;Block 1 (002000-003FFFh) not write-protected
    CONFIG WRTC = OFF ;Configuration registers (300000-30000Bh) not write-protected
    CONFIG WRTB = OFF ;Boot Block (000000-0007FFh) not write-protected
    CONFIG WRTD = OFF ;Data EEPROM not write-protected
    CONFIG SCANE = ON ;Scanner module is available for use, SCANMD bit can control the module
    CONFIG LVP = OFF ;HV on MCLR/VPP must be used for programming
    CONFIG CP = OFF ;UserNVM code protection disabled
    CONFIG CPD = OFF ;DataNVM code protection disabled
    CONFIG EBTR0 = OFF ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR1 = OFF ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
    CONFIG EBTRB = OFF ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    #ENDCONFIG


    data @0,0 'Mode tête et pied inversé Rotec
    data @1,1 'afficheur 6r pre-compile
    data @2,0 'th12 (Permobil et Span) pre-compile relais
    data @3,0 'Linak hl70d (Euro) pre-compile
    data @4,0 'TC1 (Permobil et Span serial) pre-compile pas fait
    data @5,0 'TC14 (Sotec serial) pre-compile
    data @6,0 'Umano pre-compile
    data @7,0 'Permobil Trost pre-compile
    data @8,1 'Permobil Noa TC1 relais pre-compile (Comme Span mais différents boutons/fonctions)
    data @9,0 'Bertek 9 pins pre-compile


    '************************************************* ***
    ' Initialisation des modules internes 18F46Q10 *
    '************************************************* ***


    'Analog to digital converters
    ANSELA = 0
    ANSELB = 0
    ANSELD = 0
    ANSELE = 0


    'Open Drain (NO)
    ODCONA = 0
    ODCONB = 0
    ODCONC = 0
    ODCOND = 0
    ODCONE = 0


    'Slew rate
    SLRCONA = 0
    SLRCONB = 0
    SLRCONC = 0
    SLRCOND = 0
    SLRCONE = 0


    'Input threshold (TTL)
    INLVLA = 0
    INLVLB = 0
    INLVLC = 0
    INLVLD = 0
    INLVLE = 0


    'Weak Pull-Up
    WPUA = 0
    WPUB = 0
    WPUC = 0
    WPUD = 0
    WPUE = 0


    'Timers
    T0CON1 = %01000000 'source Fosc/4
    T1CLK = %00000001 'source Fosc/4
    T2CLKCON = %00000001 'source Fosc/4
    T3CLK = %00000001 'source Fosc/4
    T4CLKCON = %00000001 'source Fosc/4
    T5CLK = %00000001 'source Fosc/4
    T6CLKCON = %00000001 'source Fosc/4


    It changed nothing. I always put a blinking led and a "beep" on startup. So I switched my PIEZO for the LED (PORTD.0). So I can see the LED "SOUND"


    sound led_1,[124,20]


    The led should be ON for about 20x12ms so 240ms. It's ON for exactly 240ms and the period is 400us (2.5Khz) All Ok here. So I "Input' my Piezo pin, place a jumper from my led (removed and 1k res removed) to the piezo. No drive, no PWM, just HIGH and then LOW after 240ms. I must be doing something wrong. I don't know.


    The second thing not working is the SERIN function. All rejected after timeout. I did not investigate this one yet.

  7. #7
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Yes I am using MPLAB X 5.35 compile OK.
    Thank you.

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    There seems that you use external crystal. What frequency is this?

    Is led_1 defined in your program?

    Is the MCLR pin tied to Vdd?

    Is TRISD.0=0?

    Ioannis
    Last edited by Ioannis; - 6th March 2025 at 20:05.

  9. #9
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Also, you missed setting PORTC to digital mode (ANSELC), so any sound or serial functions for these pins will likely have issues.

  10. #10
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Quote Originally Posted by tumbleweed View Post
    Also, you missed setting PORTC to digital mode (ANSELC), so any sound or serial functions for these pins will likely have issues.
    I changed it after my post. It was not that. I found out that even if a peripheral is disabled I had to assign a dummy port to it. (xxxPPS registers)
    For the SOUND FUNCTION (RC1) it was CCP2PPS (=0 now) same for the SERIN2/SEROUT2 FUNCTION (RB6 RB7) it was RX1PPS (=0 now) CK1PPS (=0 now)

    Thank you !

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    i see a code snippets that cannot be compiled.
    code snippets not in code tags.
    a code snippet that does not demonstrate how you have configured the device
    allegations of strange undocumented behavior that cannot be corroborated


    why don't you post the code you have tried. if you don't want to post the complete project then
    aim to post the simplest compliable program that shows the problem. code snippets generally
    don't cut it, we need to see the config settings, osc speed, var declarations, port settings etc....
    [use code tags] please, if you don't know how to do that then read the faq






    a minimal, complete and verifiable example MCVE is the best way to get help
    https://stackoverflow.com/help/minim...ucible-example
    Warning I'm not a teacher

  12. #12
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Update, it's resolved. tumbleweed was wright. I have tried to replicate the problem with the sound function and serin2/serout2 problems and it's only the ANSELC that was not set properly.

    To my "excuse" here is a picture of the Datasheet and why I dismiss ANSELC at first. Thank you Ioannis, tumbleweed and Richard. To Richard, I wrote a small program to check for the problem, but there is nothing to check anymore. The PPS registers can be ignored if the peripherals are not enabled (confirmed).

    Name:  Screen Shot 2025-03-07 at 10.57.44.398 AM.png
Views: 621
Size:  74.2 KB

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    Yes, maybe the Data sheet had a miss there. But then on page 251 there is this:

    Name:  Capture.JPG
Views: 609
Size:  100.8 KB

    So, Richard stated very well about snippets. I said earlier that only guesses we can make. Once again this was so true!

    This one would be resolved on the 2nd post.

    Ioannis

  14. #14
    Join Date
    Mar 2025
    Location
    Quebec, Canada
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: PBP3/MPLABX - PIC18F46Q10: The sound function.

    I know. Thank you Ioannis.

Similar Threads

  1. Installing PBP3.1 with MPLAB 8 AND MPLABX
    By MikeBZH in forum General
    Replies: 34
    Last Post: - 4th April 2023, 19:41
  2. MPLABX v5.35 and PBP3
    By geoffpeters in forum General
    Replies: 1
    Last Post: - 17th February 2022, 17:43
  3. How to setup pbp3 with MPLABX?
    By thasatelliteguy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 20th November 2017, 12:46
  4. Integrate PBP3 in MPLABX.
    By Ziko87 in forum PBP3
    Replies: 0
    Last Post: - 21st May 2013, 13:41
  5. Can't get ISIS/Proteus VSM to work with PBP3 and MPLABX
    By chicowoodhill in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 28th July 2012, 20:45

Members who have read this thread : 13

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