Oh, and what's your power supply?
A speaker is a pretty low impedance load. Any chance that when the speaker turns on it drags your supply voltage down to unhappy levels?
Oh, and what's your power supply?
A speaker is a pretty low impedance load. Any chance that when the speaker turns on it drags your supply voltage down to unhappy levels?
I downloaded an application that uses the sound card and provides AC osciliscope capabilities (no DC). With no speaker (load) attached I see a spike when the sound starts and a matching inverted spike when the sound stops and since I don't think it does DC I expect it's shifting to a TTL high during this period. There is no detectable waveform present. When I switched back to the note 157 (white noise) I DO see a square wave form that is random in nature. Still no clue here why it's not producing any noise for the 1-128 notes.
From the Data sheet: ANSEL and ANSELH must be configured to use port C as I/O.
Without them sound works on PortB but not PortC, the code snippet above is configured to use the MicroChip low parts count demo board.Code:;@MyConfig = @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON @MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF @ __config MyConfig DEFINE OSC 4 PortA = 0 PortB = 0 PortC = 0 TRISA = 1 TRISB = 0 TRISC = 0 i var byte ANSEL = 0 ANSELH = 0 CM1CON0 = 0 CM2CON0 = 0 main: portc = 0 pause 500 for i = 1 to 15; step -1 portC = i i=i << 1 pause 250 next i sound portB.6, [120,2,124,2,123,2,121,2] sound portC.6, [120,2,124,2,123,2,121,2] goto main end
Last edited by Archangel; - 21st March 2009 at 03:08.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Thanks very much for the help. I didn't have ANSELH and that was the missing link. Very much appreciated!
You are welcome, with appropriate credit to byte_butcher for his comment in post 7, providing me the clue. Very happy it works for you, and for what I learned helping.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
In my brief (almost 3 months now!) exposure to PIC's, one of the most important things I've learned is that if a port doesn't act the way I expect, the first thing to look for is whether or not I've got all the appropriate registers set to make sure my pin is digital or analog, input or output, etc.
I've been tripped up by that one too many times already!
Glad I could help be part of the solution for once.![]()
Bookmarks