10 years, 4 months ago.  This question has been closed. Reason: N/A

NXP LPC 1768

I'm working on mbed pin Pwmout for Mic output. I need an output of 1 or 1.2 kHz from mbed going to the low pass filter and voltage divider. After passing through the filter and voltage divider, I need an output of 1 kHz frequency and minimum voltage of 1.65 V.

Below is the code that I have written but I can not figure out problem. Any help would be appreciable.

/media/uploads/RavneetSingh/download.jpg

  1. include "mbed.h"

PwmOut micAudioOut(p24);

float pwmAudioOut = 1;

int main() { micAudioOut.period_ms(1); Period set to 1ms = 1kHz

while(1) {

for (float i = 0; i <= 1.0; i = i + 0.2){

pwmAudioOut = pwmAudioOut + i; wait(0.2);

} } }

Using code tags helps:

#include "mbed.h"
PwmOut micAudioOut(p24);

float pwmAudioOut = 1;

int main() { 
micAudioOut.period_ms(1);  //Period set to 1ms = 1kHz
while(1) {
   for (float i = 0; i <= 1.0; i = i + 0.2){
      pwmAudioOut = pwmAudioOut + i; wait(0.2);
      } 
   } 
}
posted by Christian Lerche 04 Feb 2014

What is the problem? Nothing pulsing from mbed? No tone? Compiling with error?
You do now that mic's are meant for input right?
Put a small speaker at the output of the filter.

Then try:

#include "mbed.h"
PwmOut micAudioOut

int main(){
   micAudioOut.period_ms(1);
   while(1);
}

Is an audible tone coming from the speaker?
If not, you might be using to much current from the PWM pin.
If you have a scope you could verify the output from p24.

posted by Christian Lerche 04 Feb 2014

Hi Chris I appreciate your post. Yes, audible tone is coming from the speaker.

posted by Ravneet S 04 Feb 2014

2 Answers

Ravneet S
poster
10 years, 4 months ago.

/media/uploads/RavneetSingh/untitled.png

just like this ?

You also need to set the pulsewidth of PWM.

micAudioOut.pulsewidth_us(500);
posted by Christian Lerche 04 Feb 2014
10 years, 4 months ago.

You also need to set the pulsewidth of PWM.

micAudioOut.pulsewidth_us(500);

i have tested this code on oscilloscope and signal wave is like straight lines.

posted by Ravneet S 04 Feb 2014

INsert the code above after period_ms in main.

posted by Christian Lerche 04 Feb 2014

Hi Chris, How can I send this frequency output to AnalogIn Pin15 ?

posted by Ravneet S 11 Feb 2014

Connect it using a wire.

posted by Christian Lerche 11 Feb 2014