Audio Controller

Discussion in 'Embedded Systems and Microcontrollers' started by NSCC_EETN, Feb 1, 2011.

  1. NSCC_EETN

    Thread Starter New Member

    Oct 6, 2010
    17
    0
    Hey Guys,

    My partner and I are making an audio controller using the PIC16f887. We are trying to get the keyboard we constructed to work like an actual keyboard.

    The problem we are running into is the tones coming out of the device (picture attached is a test circuit, programming is also included below). The lowest frequency we can put out is 645.5Hz and for some odd reason 0xFF is as low as we can go since we are using hex for the values (indicated in bold font). The lower the hex value we make it, the higher the frequency outputted.

    Anything we can potentially do to try and get it below that 645 so we can get the remaining keys?

    NOTE 1: This is only the main program that I am including. We have three macro programs designated for the beep, buttons and pause segments of the program which assist the main program.

    NOTE 2 : BEEP HEX1, HEX2;

    where HEX1: tone; higher the hex value, the lower the frequency. Maxxed at 0xFF.

    where HEX2: length; higher the hex value the longer the tone. Maxxed at 0xFF.




    This is the current programming we have:
    Code ( (Unknown Language)):
    1.  
    2.  
    3. ;***************************************************************************************
    4.    __CONFIG _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _DEBUG_OFF
    5.  
    6. __CONFIG _CONFIG2, _BOR40V & _WRT_OFF
    7. ; __CONFIG directive is used to embed configuration data within the .asm file.
    8. ; The labels following the directive are located in the respective .inc file.
    9. ; See the respective data sheet for additional information on the configuration word.
    10. ;****************************************************************************************
    11. ;*********************** Header ***************************************
    12. ;******************* Defining variables in program ********************
    13.        cblock      0x20
    14.        HIcnt                       ; Auxiliary variables for macro pausems
    15.        LOcnt
    16.        LOOPcnt
    17.        PRESCwait
    18.        Beep_TEMP1                  ; Belongs to macro "BEEP"
    19.        Beep_TEMP2
    20.        Beep_TEMP3
    21.        endc
    22.        
    23. #define  BEEPport PORTD, 2         ; Speaker pin
    24. #define  BEEPtris TRISD, 2
    25.  
    26.        expand
    27.  
    28. ;**********************************************************************
    29.        ORG         0x0000          ; RESET vector address
    30.        goto        main            ; Jump to program start (label - main)
    31. ;**********************************************************************
    32. ; remaining code goes here
    33.  
    34.        include     "pause.inc"
    35.        include     "button.inc"
    36.        include     "beep.inc"
    37. main
    38.        main
    39.        banksel     ANSEL           ; Selects bank containing ANSEL
    40.        clrf        ANSEL           ; All outputs are digital
    41.        clrf        ANSELH
    42.        
    43.        banksel     TRISD
    44.        movlw       b'11111011'     ; PORTA D initialization
    45.        movwf       TRISD
    46.        banksel     PORTD
    47.        BEEPinit                    ; Macro "Beep"
    48. Loop
    49.        button      PORTD,0,0,Play1 ; Push-button 1
    50.        button      PORTD,1,0,Play2 ; Push-button 2
    51.        goto        Loop
    52.        
    53. Play1                              ; First tone
    54.        BEEP        [B]0xFF[/B], 0xFF
    55.      
    56.        goto        Loop
    57.        
    58. Play2                              ; Second tone
    59.        BEEP        0xBB, 0xFF
    60.  
    61.        goto        Loop
    62.  
    63. ;**********************************************************************
    64.        END                         ; End of program
    65.  
    66.  
     
    Last edited by a moderator: Feb 1, 2011
Loading...