PDA

View Full Version : TX problem



Christopher4187
- 16th October 2005, 21:17
Hi,

I used this program on a 16F876 and it worked with no problem. I went to a 16F688 because I just needed a PIC with a USART port and less pins. Below is the code but it stops at the point where HSEROUT is. Can anyone help with it?

DEFINE HSER_BAUD 2400
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_CLROERR 1


Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
ADCON1 = %10000010
TRISC = %11000010
TRISA = %11011111
ANSEL = %10000000
CMCON0=7
b1 var BYTE
b2 var BYTE
b3 var BYTE
sum var word

mainloop:
IF PORTC.1=0 THEN SEND
GOTO MAINLOOP

send:
B1=0
B2=1
B3=0
sum = b1+b2+b3
HIGH PORTC.2
PAUSE 100
LOW PORTC.2
HIGH PORTC.0
pause 50
HSEROUT [0,b1,b2,b3,sum.byte0] <---This is where the code stops.
PAUSE 50
LOW portC.0
HIGH PORTC.2
PAUSE 1000
LOW PORTC.2
B1=0
B2=0
B3=0
GOTO MAINLOO

Darrel Taylor
- 16th October 2005, 22:08
Hi Christopher,

DEFINE LOADER_USED 1

The reason I suspect that is because in the .LST file, it shows HSEROUT as being in program address 0001h. If you are using a bootloader and not DEFINEing it, the first 3 words of HSEROUT will be lost. Causing it to jump into La-La Land.
<br>

Christopher4187
- 16th October 2005, 22:41
Darryl,

I tried what you said but it still works the same. I am so frustrated that this works on the 876 but I can't get it to work on the 688. BTW, at the end of the code it says "goto mainloo" but it should say "goto mainloop." This is just a typo. Anyway, do you have any other ideas?

Thanks,

Chris

sean-h
- 17th October 2005, 00:43
What clock speed are you running it at?

Worth adding a
DEFINE OSC with your value of clock you running.

If using internal Clock then if I remember right the 16F688 runs at 8mhz and if you have not Defined a clock speed PBP will default to 4mhz

Regards

Sean.

Bruce
- 17th October 2005, 19:07
Download the latest patch to fix this one. http://www.melabs.com/support/patches.htm

Without the patch HSEROUT/HSERIN do not work with this series. Microchip decided to shift the USART config registers (and a few more) into different file register banks.

I guess Microchip just likes to keep 3rd party compiler developers on their toes...:}

Christopher4187
- 19th October 2005, 00:48
Yup, this fixed the problem! Thanks for the help, I should have checked for updates.