programming an audio signal using pic18f and Interrupt service Routine

Home Forums Microcontrollers PIC Microcontroller programming an audio signal using pic18f and Interrupt service Routine

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #13657
    yamabonadine
    Participant

    Hi,

    I have in my pocession a microphone, an amplifier and a pic18f452. I have already connected the microphone to the amplifier. I did it on a turntable. I will connect the output of my microphone on the deck with an annalog port on the picdem Board and ground with ground on the picdem board. The channelA0 of the picdem board is reserved for the potentiometer so I have to use another port different from port A to connect the output of my Microphone, for exemple PORTC.
    concerning programming I have to write a program that allows me to digitize this analog signal from the microphone and send it through the uart of my picdem board to a module blutooth HC05. the Picdem Board have an integrated ADC (10bit).

    this is what i already do.can you suggest me anything? MY CODE

    #pragma config OSC=HS,WDT=OFF,LVP=OFF // HS Oszillator, Watchdog Timer disabled, Low Voltage Programming

    #include “p18f452.h”

    #include “lcd.h”

    extern void lcd_printf (const char* message);

    extern void lcd_gotoxy (char row,char column);

    extern void lcd_clear (void);

    extern void lcd_init (void);

    extern void lcd_byte (char num);

    extern void lcd_int (int num);

    extern void lcd_putc (char num);

    void high_prior_InterruptHandler (void);

    void low_prior_InterruptHandler (void);

    unsigned int x=0, y=0;

    unsigned char signal_in[];

    unsigned char signal_out[];

    unsigned char empfangspuffer,sendepuffer;

    #pragma code high_prior_InterruptVector = 0x08

    void high_prior_InterruptVector(void)

    {

    _asm

    goto high_prior_InterruptHandler

    _endasm

    }

    #pragma code low_prior_InterruptVector = 0x18

    void low_prior_InterruptVector(void)

    {

    _asm

    goto low_prior_InterruptHandler

    _endasm

    }

    void init (void)

    {

    lcd_init();

    lcd_clear();

    /*UART serielle Schnittstelle initialisieren*/

    RCSTAbits.SPEN = 1; // Serial Port Enabled for TX & RX

    RCSTAbits.CREN = 0; // Continuous Receive Enabled

    TXSTAbits.BRGH = 1; // High Baud Rate Selected

    SPBRG = 25; // Naud Rate = FOSC / (16(X+1)) // 4MHZ Asynch & HSpeed

    TXSTAbits.SYNC = 0;

    /*ISR ,Interrupt Serielle Schnittstelle initialisieren*/

    PIE1bits.RCIE = 1; //Enable USART Interrupt

    PIR1bits.RCIF = 0; //Clear USART RX Interrupt Flag

    IPR1bits.RCIP = 1; //High Priority Enable

    TRISCbits.TRISC6 = 1; // 0b10111111;

    //AD-Interrupts

    PIR1bits.ADIF = 0; // Clear ADC Interrupt Flag

    IPR1bits.ADIP = 0; //SET to Low Priority

    PIE1bits.ADIE = 1; // Enable ADC Interrupt

    // Allgemeine Interrupts

    RCONbits.IPEN = 1;

    INTCONbits.GIE =1;

    INTCONbits.PEIE =1;

    //AD Einstellungen

    TRISAbits.RA0 = 1; //Port RA0 Poti auf Eingang setzen

    TRISEbits.RE0 = 1; //configure RE0 as input pin for Microphone

    ADCON1=0x8B; // Make RA0/AN0 and RE0 pin as analog pin

    ADCON0=0xA9; //Fosc/32, Channel 5

    ADCON0bits.ADON = 1; // Enable ADC

    }

    /* UART Receive*/

    #pragma code

    #pragma interrupt high_prior_InterruptHandler

    void high_prior_InterruptHandler(void)

    {

    //code

    }

    /*sendung mit uart TX*/

    #pragma code

    #pragma interrupt low_prior_InterruptHandler

    void low_prior_InterruptHandler(void)

    {

    //code

    }

    /*AD Wandlung*/

    #pragma code

    #pragma interrupt low_prior_InterruptHandler

    void low_prior_InterruptHandler(void)

    {

    if(PIR1bits.ADIF == 1) //A/D-Wandlung starten

    {

    x = ADRESH; //A/D-Ergebnis Bit 2 bis 10

    y = ADRESL;

    PIR1bits.ADIF = 0;

    ADCON0bits.GO_DONE = 1; // ADC neu starten

    }

    void main()

    {

    //code

    }

    i want your help for Programming please.

    Regards

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
>