What is the minimal setup for PIC16F88

Thread Starter

NomadAU

Joined Jul 21, 2012
46
Hi,

I'm trying to debug a problem with USART on this chip. I'm familiar with using the PIC 16F628 but new to the 16F88 and am finding it a bit of a challenge to configure (particularly the clock).

I suspect my USART problem (erratic behaviour, data duplication, data sometimes not received) is due to an inaccurate clock on the mcu side, so I am going back to basics in order to get the clock configuration correct.

I have stripped everything from my breadboard and just connected the Vss and Vdd, and a resistor/LED to RB7.

Using the following program from an online source, I am expecting the LED to blink when connected to any of the digital pins. However, I get no output at all from the LED. As sometimes happens, right now it feels like I am going backwards instead of making progress with this project...

Question: Are there any ESSENTIAL connections other than Vss/Vdd and the output LED pin that I need? I assume MCLR is not in use so no need to tie this to ground.

Rich (BB code):
;***************************************************************
    title    "PIC Sample code: PIC16F88 program"
    subtitle    "Version 1.1 (c) Jay.slovak"
;Designed for 16F88 @4Mhz
;***************************************************************
    list    p=16F88
 #include "p16f88.inc"  ; PIC definitions
    __CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
    ERRORLEVEL -302
;***************************************************************
z1    equ    20h
z2    equ    21h
z3    equ    22h
z4    equ    23h
;***************************************************************
    org    0x0000
    goto    INIT
    NOP
    NOP
    NOP
    NOP
    org    0x0005
INIT
    CLRF    PORTA
    CLRF    PORTB
    BSF    STATUS,RP0    ;Select Bank 1
    CLRF    ANSEL    ;All pins are Digital
    BSF    OSCCON,6    ;Set oscilator to 4Mhz
    BSF    OSCCON,5
    MOVLW    H'07'
    MOVWF    CMCON    ;Turn off comparators
    CLRF    TRISA    ;Port A is output
    CLRF    TRISB    ;Port B is output
    BCF    STATUS,RP0    ;Select Bank 0

Start
    MOVLW    0xFF
    MOVWF    PORTA
    MOVWF    PORTB
    ;goto    $
    CALL    Delay
    CLRF    PORTA
    CLRF    PORTB
    CALL    Delay
    GOTO    Start
;***************************************************************
;***************************************************************
    subtitle    "Delay subprogram"
Delay    movlw    D'3'
    movwf    z3
    movlw    D'137'
    movwf    z2
    decfsz    z1,f
    goto    $-1
    decfsz    z2,f
    goto    $-3
    decfsz    z3,f
    goto    $-5
    return
 

t06afre

Joined May 11, 2009
5,934
Do you have a pullup on pin 4 (MCLR)?
Or just set _MCLR_OFF in the config bits. Check again if the clock speed you are using realy is 4MHz. Select a low data rate ke 9600 bit per second(if that can be done with 4MHz clock speed). I have also seen in datasheets from microchip that they warn about the internal osc used with UART my create errors. Not experienced this my self then using low data rates
 

MaxHeadRoom

Joined Jul 18, 2013
28,698
If the USART is not running at the correct baud rate, you will just get garbled characters.
The manual will show the % error for a certain clock/Baud rate.
I have had no problem with 4mHz.
Max.
 

Thread Starter

NomadAU

Joined Jul 21, 2012
46
The MCLR was the problem....I just hooked up a 10k resistor from pin 4 to Vdd and all is working. Such a basic error, but another learning for me.
BTW, before I made this change, the behaviour of the chip was affected just by the presence of my fingers. Without touching the chip, but putting my fingers close to it, I could make the LED come on. I guess this is due to me providing some capacitance and affecting the circuit, but I thought I'd mention this in case it helps anyone else with their diagnosis.
 

tshuck

Joined Oct 18, 2012
3,534
Glad you got it sorted! :)

As t06afre suggested, you can turn MCLR off in the configuration bits.

The random behavior of your controller is due to leaving the reset floating, which will float to whatever is nearby...
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
28,698
BTW, before I made this change, the behaviour of the chip was affected just by the presence of my fingers. Without touching the chip, but putting my fingers close to it, I could make the LED come on.
I recall seeing the very same effect in the early days.
Just waving your hand over the chip would make it do strange things.
Max.
 
Top