PDA

View Full Version : Will I EVER get serial communication working ?



Davidmarks
- 11th October 2011, 22:58
Earlier this year I spent hours unsuccesfully trying to operate a serial lcd with no success at all & assuming it was a dud lcd I gave up.
I now need to cotrol a quadravox sound module with serial data and once again I simply cannoy get the darned thing working. The module requires a number between 0 and 239 to identify an mp3 track. I have recorded two tracks (00 and 01) and the software provided by quadrovox for testin shows that they are there and play OK. I have now connected a PIC 1628a running at 4 mhz (crystal)
checked that it is working by writing a prog to blink an led on PortB.3 So far so good. I have now connected PortB.0 to the serial port of the module (pin 2 data receive and pin 5 ground) and having been told to muse driven inverted output have written the following program which compiles Ok but does absolutely zilch. What the devil am I doing wrong !!! If I go on like tyhis much longer matron's not going to let me out. Any helpful suggestions would be greatly appreciated
[
@device PIC16F628A
include "modedefs.bas"
DEFINE OSC 4
x VAR BYTE
loop:
pause 2000
for x= 0 to1
SEROUT Portb.3,n9600,[x]
pause 4000
next x
goto loop
end
]

pedja089
- 11th October 2011, 23:33
Try with max232 and mode T9600.
Also check if pin 2 is an input... If you use same cable as for PC port, then your Tx should be same as on PC, pin 3.
If you trying to send data to PC, then you should connect portb.0 to PC pin 2...

mackrackit
- 12th October 2011, 08:52
Read about CCP1CON, section 9 of the data sheet. Turn it off.

9600 baud can be too fast for 4MHz.

For testing try sending a string to a terminal. MCS has one built in.

Use SEROUT2 with an inverted mode less than 9600. No MAX232 required for this test.

mister_e
- 13th October 2011, 03:27
it's been said countless time here (and probably the manual state it too) SEROUT/SEROUT2 @ 9600 bauds & @ 4mhz aren't going to work accurately.. worst when using an old PIC model AND it's internal OSC.

Your best bet it at least to use the internal USART (with the according dedicated pins & hardware + DEFINEs) OR worst case use DEBUG.

simonr
- 18th December 2011, 00:24
Did you ever get the sound module to work? I've used them at 2400 baud (BR1 and BR0 low) without too many problems. It is important to check the that the module isn't busy (pin 3 on the module isn't low) before sending commands e.g:

loop:
if busy=0 then loop 'check module

SEROUT RXD,0,[$FC,62] 'set volume
SEROUT RXD,0,[0] 'play file

Also, are you sending data to pin 2 of of the module, as this is the module transmit pin and not the receive pin?

It is also a good idea to set the volume, as I have played files with no O/P only to find that the volume was set too low!

The only problem that I have with the module is that they draw 10mA when not in use and when I put in sleep mode (Of8h) I can't wake it up again!