Hello! BradTheRad
Can I just interface DAC0808 to my PIC18F4620 PORTD outputs and give the output of DAC to earphones?
I'd be surprised if the DAC provides sufficient power to drive earphones.
It's likely you'll need an audio amplifier. This can be made from an easy-to-use IC such as the LM386. There are many threads at this board discussing such projects.
You said that I have to set the DAC i/p port i.e., PORTD with the byte of the wav file read. Is it right?
In essence, yes, although there is probably more to it than that. I don't know the protocol. You'll have an easier job reading an 8-bit monaural file.
Nor have I used a microcontroller. I tried to do something similar with my VIC-20 about a quarter century ago, turning eight port contacts on and off, running it through an R-2R resistor network, all in hopes of hearing sine waves through my speakers. Not in the same league as a wav file.
You said that it has to be done 8000 times a sec. How to do that?
You must devise a loop that keeps track of time to the microsecond.
I was able to uncompress your program and read some files, but I would not know how to debug it.
I changed my wav file to 8-bit PCM 22KHz WAV file. I have attached my proteus circuit, mikroC Pro files, and MMC image file (.mmc file).
Please have a look at it and tell me what I am doing wrong. My Fosc is 8 MHz.
I have not used the DAC0808 (successfully), but I believe the B2 supply should be hooked up differently... other than putting it directly across the Vref+ and Vref- pins.
In order for the speaker to get AC, your ground (zero) needs to be between the bipolar supplies.
There is also the method of using a resistor network to perform DAC. Weighted values, or R-2R.
A few people have succeeded at the same project you are doing. See the link below. Some show videos.
**broken link removed**