Audio Controller

Thread Starter

NSCC_EETN

Joined Oct 6, 2010
17
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:
Rich (BB code):
;***************************************************************************************
   __CONFIG _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _DEBUG_OFF

__CONFIG _CONFIG2, _BOR40V & _WRT_OFF
; __CONFIG directive is used to embed configuration data within the .asm file.
; The labels following the directive are located in the respective .inc file.
; See the respective data sheet for additional information on the configuration word.
;****************************************************************************************
;*********************** Header ***************************************
;******************* Defining variables in program ********************
       cblock      0x20
       HIcnt                       ; Auxiliary variables for macro pausems
       LOcnt
       LOOPcnt
       PRESCwait
       Beep_TEMP1                  ; Belongs to macro "BEEP"
       Beep_TEMP2
       Beep_TEMP3
       endc
       
#define  BEEPport PORTD, 2         ; Speaker pin
#define  BEEPtris TRISD, 2

       expand

;**********************************************************************
       ORG         0x0000          ; RESET vector address
       goto        main            ; Jump to program start (label - main)
;**********************************************************************
; remaining code goes here

       include     "pause.inc"
       include     "button.inc"
       include     "beep.inc"
main
       main
       banksel     ANSEL           ; Selects bank containing ANSEL
       clrf        ANSEL           ; All outputs are digital
       clrf        ANSELH
       
       banksel     TRISD
       movlw       b'11111011'     ; PORTA D initialization
       movwf       TRISD
       banksel     PORTD
       BEEPinit                    ; Macro "Beep"
Loop
       button      PORTD,0,0,Play1 ; Push-button 1
       button      PORTD,1,0,Play2 ; Push-button 2
       goto        Loop
       
Play1                              ; First tone
       BEEP        0xFF, 0xFF
      
       goto        Loop
       
Play2                              ; Second tone
       BEEP        0xBB, 0xFF

       goto        Loop

;**********************************************************************
       END                         ; End of program
 

Attachments

Last edited by a moderator:
Top