See M25P32 PIC Audio **warning, other compiler**Originally Posted by toofastdave
Includes hardware SPI routines.
Norm
See M25P32 PIC Audio **warning, other compiler**Originally Posted by toofastdave
Includes hardware SPI routines.
Norm
Hi,
If you use an 8 MHz crystal as your oscillator and let your timer0 run free it would interrupt @ 7.8Khz (Thanks to MisterE for the PIC multicalc utility). Enable timer0 interrupt. In the interrupt routine you don't need to reload timer0 as it already rolls over. This assures a solid timebase interrupting at fixed intervals. On the interrupt set the Go/Done bit of your ADC. Use the ADC in 8 bit mode. When the conversion is done. Simply dump the ADRESH value to the PWM duty register. All this happens in the interrupt routine. Let the AD module run continuosly so that sampling (acquisition) actually occurs when you are outside the interrupt. This should be quite simple to achieve. You get enough time outside the ISR to decide whether the ADC is sampling 0 or say 127 (when you are DC offsetting the Audio that gives you a 0 for the most negative peak, and 255 for most positive sort of pseudo signed ADC you loose resolution again, distort more).
Regards
Sougata
I'll have to look into this..it sounds interesting but it may keep my PIC busy for longer than I'd want it to be at any given time, especially if I have to monitor the start and end of the audio to communicate via SPI to another device. I'll play around with it though...Thanks for the great suggestion!
sougata,
Do you have any example code of this application? It sounds like something I would like to try but ASM interrupts are over my head...I haven't gotten the whole interrupt concept down just yet...I'd appreciate anything you had to share to help me understand this idea.
Thanks!
Dave
Try a precision full wave rectifier feeding a comparator with a reference set by a pot. This will give a logic level output you can poll using the PIC. When it's high, enable the amplifier, when it falls low activate your white noise burst. Try generating random numbers (8 bit) and feeding them to a 2R2 DAC, you could even just switch a diode noise source output into the amp input.
I did somethineg VERY similar for a company as a water leak detector. A microphone listened for a noise in the pipes then activated an alarm if the noise was of a certain type and exceeded a certain duration.
Hope this helps
Norm,
Great project. I think I read about it last week when I was searching for PIC Audio Projects. Thanks for the link and the additional info. Where did you originally get the info for the SPI harware routines if they aren't in the PBP or Proton Manual?? Does RealBasic cover it in their manual?
Learn hardware SPI routines:
1.Read data sheet timing diagrams.
2.Test with working SHIFTOUT and SHIFTIN program. (SHIFTOUT pbp & SHOUT proton are almost identical)
3.Bitbang above program, something like:
low CS pin
pause
low clock pin
pause
high dataout pin (bit 7 = 1)
pause
high clock pin
pause
low clock pin
pause
low dataout pin (bit 6 = 0)
etc.
Watch on scope or if you don't have a scope make a led driver with pin > N channel FET > pullup & P channel FET > LED.
4.Now timing known. Read PIC 452 data sheet page 130 for your SPI configuration of
SSPSTAT = %01000000
SSPCON1 = %00100010
See SPI clk speed adjustment post 13.
Hardware SPI extremely fast compared to SHOUT.
Sends and receives in 3line instruction.
Norm
Bookmarks