dum311
Junior Member level 1

mplab portable
Hello everyone!
I am doing Digital Navigation Aids. It consists of a P18F4620 Microcontroller, ISD2560 voice record/playback chip LM4808M amplifier, 5volts and 3.3volts voltage regulators and three switches, the recording switch, the playback switch. First, i should record a message into the chip by pressing SW3. Then by pressing SW4, it should playback my voice.
My objectives are to create a portable device that can be used to record a message and playback the message at 1 time only using PUSH-BUTTON MODE application.
Using MPLAB IDE v7.40 - C Language.
My problem:
When the record button is pressed, voice is not recorded in the chip. The code for the playback button is also not working.
here is the programming:
#include <p18f4620.h> //for special function register declarations
#include <portb.h> //for the RB0/INT0 interrupt
#include <delays.h>
#define PR PORTCbits.RC2
#define PD PORTDbits.RD7
#define CE_ PORTDbits.RD6
#define EOM_ PORTCbits.RC3
void Init(void)
{
PD=1;
CE_=1;
PR=1;
PORTCbits.RC4 = 0; //sets RC4 pin low
PORTBbits.RB5 = 0; //sets RB5 pin low
PORTBbits.RB4 = 0; //sets RB4 pin low
PORTBbits.RB3 = 0; //sets RB3 pin low
PORTAbits.RA5 = 0; //sets RA5 pin low
PORTAbits.RA4 = 1; //sets RA4 pin high
PORTEbits.RE2 = 0; //sets RE2 pin low
PORTEbits.RE1 = 0; //sets RE1 pin low
PORTEbits.RE0 = 0; //sets RE0 pin low
}
void Mode(void)
{
CE_=0; //to start record/playback
Delay10KTCYx (200);/*Delay in multiples of 2,000,000 instruction cycles. Delay for 500 milliseconds */
CE_=1; //take CE back to high to stop record/playback
}
void Record (void);
void Playback (void);
#pragma code HIGH_INTERRUPT_VECTOR = 0x8
void high_ISR(void)
{
if(INTCONbits.INT0IF==0) //interrupt routines
{
_asm
goto Record
_endasm
}
if(INTCON3bits.INT1IF==0)
{
_asm
goto Playback
_endasm
}
}
#pragma code //allow the linker to locate the remaining code
#pragma interrupt Record
void Record(void)
{
PD=0; //take PD to low state
Delay10KTCYx(200);/*Delay in multiples of 2,000,000 instruction cycles. Delay for 500 milliseconds */
PR=0; //take PR pin to low
CE_=1;
Mode();
EOM_=1;
Delay10KTCYx (200);/*Delay in multiples of 2,000,000 instruction cycles. Delay for 500 milliseconds */
while(!PORTBbits.RB0)
{
INTCONbits.INT0IF=0; //clear flag to avoid another interrupt
Init();
}
}
#pragma interrupt Playback
void Playback(void)
{
PD=0; //set PD to low
PR=1; //take PR to high
CE_=1;
Mode();
while(!PORTBbits.RB1)
{
INTCON3bits.INT1IF=0;
Init();
}
}
void EnableHighInterrupts(void)
{
RCONbits.IPEN =1; //enable interrupt priority levels
INTCONbits.GIEH=1; //enable all high priority interrupts
}
void WaitForButton(void)
{
INTCONbits.RBIF=0;
Init();
while(1); //wait for the SW3 button to be pressed
}
void main(void)/*this program does not require user input from keyboard in order to execute it*/
{
/*Initializing PORTA*/
LATA = 0x00; //Initialize PortA by clearing output data latches
PORTA = 0x00;
ADCON1 = 0x0F; //Configure A/D for digital inputs
TRISA = 0x0F; //RA<3:0> as inputs, RA<4:5> as outputs
//RA<6:7> as "0" when not used as port pins
CMCON = 0x07; //Configure comparators for digital inputs
/*Initializing PORTB*/
LATB = 0x00; //Initialize PortB by clearing output data latches
TRISB = 0xC7; //RB<2:0> & RB<7:6> as input, RB<5:3> as outputs
/*Initializing PORTC*/
LATC = 0x00; //Initialize PortC by clearing output data latches
TRISC = 0x20; //RC5 as inputs, RC<7:6> & RC<4:0> as outputs
/*Initializing PORTD*/
//PORTD = 0x00;
LATD = 0x00; //Initialize PortD by clearing output data latches
TRISD = 0x00; //RD<7:0> as outputs
/*Initializing PORTE*/
LATE = 0x00; //Initialize PortE by clearing output data latches
TRISE = 0x00; //RE<7:0> as outputs */
EnableHighInterrupts();
OpenRB0INT(PORTB_CHANGE_INT_ON & //enable the RB0/INT0 interrupt
PORTB_PULLUPS_ON & //configure the RB0 pin for input
FALLING_EDGE_INT); //trigger interrupt upon SW3 button
//depression
OpenRB1INT(PORTB_CHANGE_INT_ON &
PORTB_PULLUPS_ON &
FALLING_EDGE_INT);
WaitForButton();
}
thank you very much.i am looking forward to your replies as soon as possible
Hello everyone!
I am doing Digital Navigation Aids. It consists of a P18F4620 Microcontroller, ISD2560 voice record/playback chip LM4808M amplifier, 5volts and 3.3volts voltage regulators and three switches, the recording switch, the playback switch. First, i should record a message into the chip by pressing SW3. Then by pressing SW4, it should playback my voice.
My objectives are to create a portable device that can be used to record a message and playback the message at 1 time only using PUSH-BUTTON MODE application.
Using MPLAB IDE v7.40 - C Language.
My problem:
When the record button is pressed, voice is not recorded in the chip. The code for the playback button is also not working.
here is the programming:
#include <p18f4620.h> //for special function register declarations
#include <portb.h> //for the RB0/INT0 interrupt
#include <delays.h>
#define PR PORTCbits.RC2
#define PD PORTDbits.RD7
#define CE_ PORTDbits.RD6
#define EOM_ PORTCbits.RC3
void Init(void)
{
PD=1;
CE_=1;
PR=1;
PORTCbits.RC4 = 0; //sets RC4 pin low
PORTBbits.RB5 = 0; //sets RB5 pin low
PORTBbits.RB4 = 0; //sets RB4 pin low
PORTBbits.RB3 = 0; //sets RB3 pin low
PORTAbits.RA5 = 0; //sets RA5 pin low
PORTAbits.RA4 = 1; //sets RA4 pin high
PORTEbits.RE2 = 0; //sets RE2 pin low
PORTEbits.RE1 = 0; //sets RE1 pin low
PORTEbits.RE0 = 0; //sets RE0 pin low
}
void Mode(void)
{
CE_=0; //to start record/playback
Delay10KTCYx (200);/*Delay in multiples of 2,000,000 instruction cycles. Delay for 500 milliseconds */
CE_=1; //take CE back to high to stop record/playback
}
void Record (void);
void Playback (void);
#pragma code HIGH_INTERRUPT_VECTOR = 0x8
void high_ISR(void)
{
if(INTCONbits.INT0IF==0) //interrupt routines
{
_asm
goto Record
_endasm
}
if(INTCON3bits.INT1IF==0)
{
_asm
goto Playback
_endasm
}
}
#pragma code //allow the linker to locate the remaining code
#pragma interrupt Record
void Record(void)
{
PD=0; //take PD to low state
Delay10KTCYx(200);/*Delay in multiples of 2,000,000 instruction cycles. Delay for 500 milliseconds */
PR=0; //take PR pin to low
CE_=1;
Mode();
EOM_=1;
Delay10KTCYx (200);/*Delay in multiples of 2,000,000 instruction cycles. Delay for 500 milliseconds */
while(!PORTBbits.RB0)
{
INTCONbits.INT0IF=0; //clear flag to avoid another interrupt
Init();
}
}
#pragma interrupt Playback
void Playback(void)
{
PD=0; //set PD to low
PR=1; //take PR to high
CE_=1;
Mode();
while(!PORTBbits.RB1)
{
INTCON3bits.INT1IF=0;
Init();
}
}
void EnableHighInterrupts(void)
{
RCONbits.IPEN =1; //enable interrupt priority levels
INTCONbits.GIEH=1; //enable all high priority interrupts
}
void WaitForButton(void)
{
INTCONbits.RBIF=0;
Init();
while(1); //wait for the SW3 button to be pressed
}
void main(void)/*this program does not require user input from keyboard in order to execute it*/
{
/*Initializing PORTA*/
LATA = 0x00; //Initialize PortA by clearing output data latches
PORTA = 0x00;
ADCON1 = 0x0F; //Configure A/D for digital inputs
TRISA = 0x0F; //RA<3:0> as inputs, RA<4:5> as outputs
//RA<6:7> as "0" when not used as port pins
CMCON = 0x07; //Configure comparators for digital inputs
/*Initializing PORTB*/
LATB = 0x00; //Initialize PortB by clearing output data latches
TRISB = 0xC7; //RB<2:0> & RB<7:6> as input, RB<5:3> as outputs
/*Initializing PORTC*/
LATC = 0x00; //Initialize PortC by clearing output data latches
TRISC = 0x20; //RC5 as inputs, RC<7:6> & RC<4:0> as outputs
/*Initializing PORTD*/
//PORTD = 0x00;
LATD = 0x00; //Initialize PortD by clearing output data latches
TRISD = 0x00; //RD<7:0> as outputs
/*Initializing PORTE*/
LATE = 0x00; //Initialize PortE by clearing output data latches
TRISE = 0x00; //RE<7:0> as outputs */
EnableHighInterrupts();
OpenRB0INT(PORTB_CHANGE_INT_ON & //enable the RB0/INT0 interrupt
PORTB_PULLUPS_ON & //configure the RB0 pin for input
FALLING_EDGE_INT); //trigger interrupt upon SW3 button
//depression
OpenRB1INT(PORTB_CHANGE_INT_ON &
PORTB_PULLUPS_ON &
FALLING_EDGE_INT);
WaitForButton();
}
thank you very much.i am looking forward to your replies as soon as possible