CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC24EP - Generate 16kHz from a short-sync 8kHz interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC24EP - Generate 16kHz from a short-sync 8kHz interrupt
PostPosted: Mon Apr 29, 2024 8:00 am     Reply with quote

Device: PIC24EP512GP806
Compiler: 5.116

Good day all,

Scenario: I want to interface a PDM microphone to a modem. The modem accepts only 16-bit PCM audio and it's the modem that must generate the clocking because that's how it works as per the manufacturer, there's no other way around that. Currently, the modem generates a 2.048MHz 50% PWM and an 8kHz short-sync clock to a CODEC. On the CODEC's front-end, I have an analog microphone. With the modem's clocks to the CODEC, the CODEC outputs a 16-bit audio stream to the modem. This is currently working over the cell network. Now, what I want to do is eliminate the CODEC and the analog mic and connect a PDM mic to the modem. This requires interfacing with an ADAU7002 PDM to PCM converter (as I have indicated in a previous post) and for sure, will require my PIC24.

The ADAU7002 is on a dev board, the modem frequencies are giving me some grief and many constraints need to be followed:

- My setup must use the modem's 2.048MHz and do something with the 8kHz short sync.

- The ADAU7002 requires a minimum BCLK of 256kHz with a minimum 64:1 ratio with the LRCLK. The ratio is automatically calculated by the IC and the LRCLK must be minimum 4Khz (64x 4kHz = 256kHz). The ADAU7002 takes ratios of 64, 128, 192, 256, 384 and 512.

- The combination of BCLK and LRCLK is what will generate the PDM clock on the PDM side of the ADAU7002 which will then send it to the microphone and in return, the microphone will send its PDM audio to the ADAU7002's PDM input after which it will convert it to a 20-bit PCM audio stream. I'll deal with the 20-bit to 16-bit down-sampling later.

- The microphone's PDM clock can only run between 600kHz and 3.3MHz therefore the modem's 2.048MHz is perfect for that.

- The PDM clock out of the ADAU7002 is fixed at 64x the LRCLK input's clock (not to confuse with the BCLK:LRCLK ratio described above with multiple ratios.... this is the LRCLK:PDMCLK ratio and is fixed to 64).

- The ADAU7002's BCLK will be the modem's 2.048MHz and in order to have a valid ratio that will also work with the PDM microphone's constraints, I have only two options considering that the BCLK will be the modem's 2.048MHz:
1) An LRCLK of 16kHz for a 128:1 ratio --> 16,000 x 128 = 2,048,000 BCLK --> will generate a 1.024MHz PDM clock
2) LRCLK of 32kHz for a 64:1 ratio ---> 32,000 x 64 = 2,048,000 BCLK --> will generate a 2.048MHz PDM clock

- Lastly, the only other clock I have available that is synched with the 2.048MHz is the 8kHz.

Somehow, I guess I need to send that 8kHz short synch pulse to the PIC probably as an interrupt-on-change and from that, I need to generate a 50% 16kHz or 32kHz clock in order to be within the constraints.... now my question is: any idea on how to do that?!

Sorry for the long explanation for something that seems simple but the constraints I have are problematic and I wanted to give the whole picture to avoid the back and forth questions and assumptions.

Does all this make sense? Any idea?

Many thanks!

Ben
temtronic



Joined: 01 Jul 2010
Posts: 9134
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Apr 29, 2024 9:11 am     Reply with quote

Ouch, my head hertz ! too many numbers, not enough coffee.....

OK, thinking outside the box....

Could you use a 'gluPIC' to do what you need ?

Some silly 8 pin,50 cent PIC that does the 'conversion/control/signalling' ?

Jay
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Mon Apr 29, 2024 9:19 am     Reply with quote

The PCB with the analog mic is already built and programming all done and all works. I soldered little wire-wrap wires on certain pins and just trying to figure-out how to convert short-sync 8kHz pulse to 16kHz 50% duty.
gaugeguy



Joined: 05 Apr 2011
Posts: 290

View user's profile Send private message

PostPosted: Mon Apr 29, 2024 12:51 pm     Reply with quote

It seems like you would need to use the 8kHz pulse to trigger a one-shot pulse and would go low for 31.25us and then go back high.
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Mon Apr 29, 2024 1:09 pm     Reply with quote

Yep, that's also what I was thinking but I wasn't sure if a timer would be able to count such as low amount of ticks to make-up for 31.25uS.

I'll have to investigate this further.

Thanks for your input!

Ben
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group