
Originally Posted by
Darrel Taylor
Hint:
There are 2 buttons available in mister-e's program ...

OK, I judge by the exchanges between DT and Mackrackit that I should have used the DEFINES button with Mister_e's PICMultiCalc. So I did. However, as a change in approach to my troubleshooting to isolate this UART problem with my PBP code, I have taken the following approach:
1) Since I know that my EasyPic6 UART interface works with the sample loopback routine that came with it that is written in microelekBasic (see earlier post) for a 16F887 chip, I have discarded my 18F4550 chip for now to see if I can get PBPro code that is functionally identical to the microBasic routine to also work with the 16F887 chip in the EasyPic6.
2) I have insured the _configs for my code result in the identical config bits that are generated by the microBasic code with the EasyPic6.
3) Please see this PBPro code below and note the configs that appear to be equivalent to the microBasic version and also how I used PICMultiCalc to define the UART setup and then studied the data sheet for the 16F877 to make sure it was correct, as shown by my extensive commenting of the UART setup.
4) I then programmed the 16F887 chip using MCSPlus, PBPro 2.6 compiler, MPASM assembler, and the PICFLASH interface to actually download the .hex file to the chip. PICFLASH also permits me to double check the configs before burning the chip.
5) After the chip is running, I then tried HYPERTERM to type some characters over the interface. Nothing indicated on HYPERTERM in the received loopback, although this same process worked with the microBasic routine.
6) Also tried the comm interface in MCSPlus to communicate with the running code and although it showed that the typed characters were accumulating in the TX tally at the bottom of the screen, no characters were being tallied in the RX entry. SAME PROBLEM AS OBSERVED WITH 18F4550!!
7) In all of the above cases I assured that both the PC and the PIC ends of the EUART interface were set to COM1/9600/8bits/no parity/1 stop bit.
The continuing failure of the PBPro code, that is as close to identical to the microBasic code as I can make it, is very frustrating to me!
Can anyone see what is wrong with this PBPro code to cause it to continue to fail in this loopback test between a PC terminal and the running PIC??
Code:
;--- if you un-comment these, you must comment the ones in the .inc file--
ASM ; 16F887, 8mhz crystal
__CONFIG _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _IESO_ON & _FCMEN_ON & _LVP_OFF & _CP_OFF & _BOR_OFF
ENDASM
Include "Modedefs.Bas"
DEFINE OSC 8
'Register Settings
TRISB = %00000000 ' Set PORTB to outputs as test LEDs
TRISC.6 = 1 ' EUSART control will automatically reconfigure
TRISC.7 = 1 ' these pins from input to output as needed.
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
' RCSTA.7 = SPEN = 1 for Serial port enabled (configures
' RX/DT & TX/CK pins as serial port pins).
' RCSTA.4 = CREN = 1 for Asynchronous Continuous Receive
' Therefore RCSTA = %10010000 = 90h
DEFINE HSER_TXSTA 20h ' Enable transmit, 8-bit, Asynchronous mode
' TXSTA.5 = TXEN = 1 for Transmit enabled
' TXSTA.4 = SYNC = 0 for Asynchronous mode
' TXSTA.2 = BRGH = 0 for High Speed Asynchronous Baud Rate
' Therefore TXSTA = %00100000 = 20h
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 51 ' 9600 Baud @ 8MHz, 0.16%, , 51 = 33h = %00110011
SPBRGH = 0
BAUDCTL.3 = 1 ' Enable 16 bit baudrate generator
INCLUDE "ALLDIGITAL.pbp" ' Sets all registers for digital ops.
' User must make sure the AllDigital.pbp file
' is in same directory location as this source
' code before compiling.
PORTB = 0 ' Turn off the LEDs
HIGH PORTB.4 ' Blink the one Test LED as proof MCU is running
PAUSE 500 ' at tiime of power up.
LOW PORTB.4
' Declare variables
X VAR BYTE ' Variable holds received character from UART
START:
HSERIN [DEC X]
PORTB.5 = 1 ' Turn on PortB.6 LED if this statement is executed
' as a test of receiving a character.
HSEROUT [DEC X,$d,$a]
PORTB.6 =1 ' Turn on PortB.7 LED if this statement is executed
' as a test of HSEROUT having sent a character.
GOTO START
Bookmarks