PDA

View Full Version : Need assistance with code



mrCizzo
- 2nd May 2009, 17:47
I am trying to program a PIC16F887 to convert letters into the corresponding morse code and then output it through a speaker. The problem I am having is how to change the frequency of the output.

I'm using assembly/machine language so it's a little rough in terms of trying to get any help with it. I would imagine it would have to be the OSCCON register but I can't seem to figure out how to make it output at 1kHz.

Any help would be greatly appreciated.

Michael Wakileh
- 28th June 2009, 17:19
The osccon register controls the frequency of the internal clock if you are using it. I am unfamiliar with assembly language but I think you simply need to use NOP commands/ pauses to correctly time how long a pin is on/off...

Melanie
- 28th June 2009, 19:29
NOP = 1uS @ 4MHz

Set pin High, add 500 NOP statements, Set pin Low, add 500 NOP Statements... repeat... suppose that's one way of outputting 1KHz...

Do a forum SEARCH for Morse Code... I remember doing an example some time in pre-history...

Ah... here it is...

http://www.picbasic.co.uk/forum/showthread.php?p=31031#poststop