PIC16F88 would be a better choice, internal osc can run up to 8MHz AND you can fine-tune it... for what it worth as it's an RC osc![]()
PIC16F88 would be a better choice, internal osc can run up to 8MHz AND you can fine-tune it... for what it worth as it's an RC osc![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
The saga continues...
For a new design, I am using a PIC16F877A and trying to communicate serially with this same MP3 player - essentially running the same code that I had on the 628. You will recall that I "solved" my problem with the 628 design by moving my serial RX an TX pins from PORTA.0 and A.1 to B.6 and B.7. Bruce explained that my problem was due to A.0 and A.1 being Schmitt Trigger (ST) type buffers instead of TTL. I am assuming that what he is implying is that if your pin is a ST, you can not use it for serial communication. Is that correct?
For my new design on the 877a, I had intended to use pins E.1 and E.2 for communication but, alas, they are ST... I tried moving the serial comm to pins A.2 and A.3 which are TTL and still do not seem to be able to talk to the player. Right now, I am not using a MAX232, just going straight from the PIC pins to the TX and RX pins on the player - just as I am doing with the 628 design. It works on that board, but not on the 877. BTW, I am running both at 20 mHz.
Can anyone shed some light on this?
Thanks!
Nope. If you're using an ST type input this just means that your external device sending serial data to the PIC has to meet the minimum input threshold levels for the ST input.I am assuming that what he is implying is that if your pin is a ST, you can not use it for serial communication. Is that correct?
As for the portA pins, have you disabled A/D so you can use these pins as digfital inputs?
Bruce - Thanks for your reply. What you said is starting to make sense... For a ST pin to recognize input, it has to reach ~4V. For a TTL pin to recognize input, it has to only reach ~2V. Is that correct? So what you are saying is that in order to use a ST pin for serial input, the "signal" needs to be ~4+ Volts. And I am assuming that in most cases this would require a MAX232 to achieve those levels. Correct?
OK, let's just forget about the input for the time being. Can I use a ST pin for TXmit without any problems? Right now, the program transmits (supposed to) the commands to start playing when it receives a trigger. Well, I don't seem to be able to do that either. Any thoughts?
Here's my code:
Code:INCLUDE "modedefs.bas" 'Needed for serial communication @ DEVICE HS_OSC ; Hi Speed Osc ADCON1 = 7 ' Set PortA Pins as I/O pins CMCON = 7 Trigger var PORTC.6 PlayLED var PORTD.1 TXPin var PORTA.2 'E.1 RXPin var PORTA.3 'E.2 B0 var byte CR CON 13 ' constant value of a carriage return '**************************************************************** low playled '**************************************************************** PAUSE 3000 'allow VMusic2 to initialize SEROUT txpin, T9600,["VST",CR] 'stop anything that's playing '**************************************************************** Loop0: if trigger = 0 then goto loop0 'button is pulled low via 10K resistor high playled SEROUT txpin, T9600,["VPF file000.mp3",CR] 'Play a file named "file000.mp3" PAUSE 2000 SERIN rxpin, T9600, [">"],B0 'Waits for ">" to indicate playing done low playled PAUSE 2000 goto loop0 end
Look in the Electrical Characteristics section of the PIC data sheet. Look under Input
High Voltage. For a Schmitt Trigger type input you'll see something like 0.8 Vdd under
the Min column with Vdd under the MAX column.
What this means is; Minimum input that will be recognized as a logic 1 would be about
0.8 times Vdd. The MAX input level of course should not exceed Vdd.
Now look a bit farther to the right under Conditions. If this states "for entire Vdd range"
then this means 0.8 times whatever voltage you're operating at, that is within the spec
for Vdd, would be what you use for the input threshold calculation.
I.E. if the PIC you're using can operate from say 4V to 5.5V, then you would use whatever
Vdd is to figure this out.
Let's assume you're using a 4V supply. 0.8 * 4V = 3.2V. This would be the minimum input
level you need on the ST input to be recognized as a solid logic 1. This is the logic 1 input
threshold level.
Now look at the TTL input requirement. It may look something like this. Under the Min
column it shows 2. Under the Max column it shows Vdd. To the right it may be something
like 4.5V ≤ VDD ≤ 5.5V
2V is the minimum input level that will be recognized as a logic 1. Vdd is of course the MAX.
The 4.5V ≤ VDD ≤ 5.5V means (if Vdd is greater than or equal to 4.5V and less than or
equal to 5.5V), then you're operating within spec.
Output levels are also listed just below this section. A pin outputting a logic 1 will normally
be Vdd-0.7V, which just means you can expect a drop of around 0.7V due to the output
driver. If you're operating at 5V, then 5V-0.7V is what you can expect the output pin to
deliver to the load.
Yep. ST only refers to input pins. The DC Characteristics section of the data sheet willCan I use a ST pin for TXmit without any problems?
show what you can expect for a drop in the output driver. Normally it's around Vdd-0.7,
but it never hurts to check.
Bruce - Thanks for your elegant explanation - I now perfectly understand the difference between ST and TTL level inputs. Nicely stated!
And what you said about ST pins being used as xmit pins indicates that I should probably not have a problem doing that (I'm running at 5V, btw). Did you see any problem with my code as to why I don't seem to be transmitting to the player? Since I am not using a 232 chip, I am using the T9600 command (as opposed to the N9600 command). The Xmit and RCV pins (A.2 and A.3) are wired directly to the Xmit and RCV pins of the player. Should I be doing anything special with these connections? Like I said earlier, this works fine on my 628 board.
I appreciate your help. I am at wits end - it just doesn't make sense... Thanks!
How do you know that you're not transmitting data to the player?
Have you looked at the tx output with a scope? Have you tried inverted mode?
Could be your player requires inverted serial. That would explain why it isn't responding.
Edit: You show @ DEVICE HS_OSC but you don't show any DEFINE OSC. If you're using
anything other than 4MHz, you'll want to define that oscillator speed. PBP assumes 4MHz
unless you specify otherwise, and that will for sure screw-the-pooch with timing if you're
not using a 4MHz osc. If you are using a 4MHz osc, you may want to switch to @ DEVICE
XT_OSC so you're not over-driving your 4MHz osc.
Last edited by Bruce; - 21st August 2008 at 23:06.
Bookmarks