PDA

View Full Version : SEROUT 12F683 and GPIO.5



AvionicsMaster1
- 16th March 2013, 15:22
Ladies and Gents,
I'm playing with Proteus and serial outputs on a 12F683 using GPIO.5 as my output to the serial display. When I use this code
clear
trisio = %001000
gpio = 0

INCLUDE "modedefs.bas"
DEFINE CHAR_PACING 1000


define osc4
osccon = %01101110 ' sets int osc to 4 mhz

ansel = 0 ' all ports digital
cmcon0 = 7 ' comparators off
adcon0 = 0 ' adc off

b var byte
c var byte
y var byte
pinout var gpio.5


beginning:
let b = 0
let c = 0
for b = 0 to 15
'serout gpio.5,n9600,[10,13,13]
' pause 500
serout gpio.5,n9600,["b=",#b," c=",#c,10,13,13]
' pause 500
y = y + 1
serout gpio.5,n9600,["number of trips ",#y,10,13,13]
if b < 8 then
gpio = b
else
c = b + 8
gpio = c
endif
pause 500
next b

goto beginning I get what I expect. That is LEDs hooked up to a 74154(?) BCD to 16 decoder counting from 0 to 15 and serial out to a display that can be read by humans.

However, when I try to go to 8MHZ internal oscillator using this change
define osc8
osccon = %01111110 ' sets int osc to 4 mhz the LEDs count like expected but the serial out goes into Alien script mode.

I haven't tried using another output pin as I'm unsure if that's the problem.

Now the $64 question: Is there something special about GPIO.5 that needs to be accounted for to get serial out on that pin?

Let the schooling begin!

HenrikOlsson
- 16th March 2013, 15:56
Have you tried it on real hardware?
Your OSCCON seems correct for 8MHz but it's my understanding that you ALSO have to tell Proteus at which frequency the virtual PIC is supposed to be running, it doesn't actually use the value of the x-tal or, in this case, the internal oscillator. I've never used it though so I may very well be wrong.

/Henrik.

Darrel Taylor
- 16th March 2013, 17:45
Proteus will adjust the internal oscillator frequency according to the OSCCON register, which overrides the oscillator frequency set in the parts dialog box.

But your define osc8 is not correct.
It should be ...

DEFINE OSC 8

Without a correct DEFINE OSC, PBP assumes it is 4Mhz.

AvionicsMaster1
- 19th March 2013, 20:47
Thanks, that appears to have fixed it. It's often the simplest of things.

AvionicsMaster1
- 29th March 2013, 00:00
I went back to this program after doing some other things and found I'd missed part of the point. My define statement should have been in all caps and not used lower case characters. All the defines are case sensitive not just the define oscillator. I wish PBP would throw up an error during the complile as it surely could check for that. Of course, I may have shut that attention getter off at some previous session.

I've promised myself I'd look back over the manual again to acquaint myself with the nuance of the language. Oh joy!

Demon
- 4th April 2013, 22:26
It would be nice if microcode studio would make a permanent substitution along with a warning.

Robert

mackrackit
- 4th April 2013, 22:58
Just code pbp with caps locked on... Then no worries .