+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    9

    Default 16F887 hersout doesn't work

    Hello everybody,

    can someone help me with this problem? Why is this code not working?

    CLEAR

    ;-- 16F887 external OSC @ 20Mhz ------
    DEFINE OSC 20
    OSCCON = 0 'SET SYSTEM CLOCK SWITCH BIT

    ;----- Configuration bits ------------------------------------------------
    #CONFIG
    Line1 = _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_ON
    Line2 = _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_ON & _HS_OSC

    __CONFIG _CONFIG1, Line1 & Line2
    __CONFIG _CONFIG2, _WRT_HALF & _BOR40V
    #ENDCONFIG

    DEFINE HSER_RCSTA 90h ' Enable Serial PORT
    DEFINE HSER_TXSTA 24h ' Enable transmit
    DEFINE HSER_SPBRG 129 ' set USART to 9600 baud (when BRGH=1)
    DEFINE HSER_CLROERR 1 ' Enable automatic overrun error

    ANSEL=0 ' A/D disabled for ANS0 to ANS7
    ANSELH=0 ' A/D disabled for ANS8 to ANS13
    CM1CON0 = 0 ' Disable comparators
    CM2CON0 = 0 ' These default to disabled at POR, but just in case
    CM2CON1 = 0
    ADCON1 = 7
    IOCB = 0
    INTCON = 0



    Start:

    hserout ["hello", 10, 13]

    Pause 1000

    goto start
    end

  2. #2
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: 16F887 hersout doesn't work

    I guess the 1st thing to look at is the hardware setup.

    Is there voltage being applied to the correct rails and is that voltage correct.
    Is your serial cable plugged into the correct pin
    Have you pulled up your MCLRE pin (as it's switched on)
    Can the chip flash an LED or toggle a pin to verify it's working

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default Re: 16F887 hersout doesn't work

    I would add also these:

    DEFINE HSER_BAUD 9600

    And depending on the electric connection of your serial output (TTL or Inverter driver like MAX232 chip) also see this register:

    BAUDCTL = %00010000 for TTL output

    BAUDCTL = %00000000 for MAX232 chip

    And of course make sure that you PIC is running having a LED flashing checking its frequency too.

    MCLR seems active so it have to be tied to Vdd.

    Ioannis
    Last edited by Ioannis; - 10th August 2019 at 21:27. Reason: typo...

  4. #4
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: 16F887 hersout doesn't work

    MCLR seems active so you have to be tied to Vdd.
    Yeah, that one got me a beauty recently. Over the years I've probably programmed maybe a dozen different flavours of PIC and every single one of them had a config switch to disable the MCLR and I naturally turn it off for all my projects... like... automatically.
    So I get to the PIC18F27J53 and I'm experimenting writing to flash (something I've never done before) and wondering why it wasn't working. There was assembler code involved so I naturally assumed it was a coding issue. Hours and hours of head scratching later, after going over the datasheet, like, hundreds of times, I succumbed to glancing over the "guidelines for getting started" chapter. Seeing the tying of the MCLR prompted me to check my config switches just to check it was disabled. HUHHHH!!! There is no switch to disable it!!! Damn it!
    So, obviously from now on my 28 pin homemade programmer board has a MCLR tie up just in case.

    Troy

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default Re: 16F887 hersout doesn't work

    Before anything serious, I always try the stupid LED flash test program, best on a pin with no ADC, PWM etc. This way I am sure, clock is OK, configs are OK, so I can move on to the more juicy stuff.

    Ioannis

Similar Threads

  1. pic16f88 doesn't work at all
    By aswasw3 in forum General
    Replies: 1
    Last Post: - 15th April 2016, 04:47
  2. Attachements doesn't work.
    By HenrikOlsson in forum Forum Requests
    Replies: 15
    Last Post: - 14th September 2013, 03:04
  3. first project, and yes, doesn`t work
    By bogdan in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 28th April 2009, 06:13
  4. why this doesn't work?
    By strasni_betmen in forum Serial
    Replies: 7
    Last Post: - 4th September 2008, 15:56
  5. HSERIN doesnt work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

Members who have read this thread : 12

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts