Menu

Trouble with 16F15224

Frank
2022-12-08
2022-12-13
  • Frank

    Frank - 2022-12-08

    Hi!
    Is it possible/probable that the config file for the 16F15224 has errors? I did not succeed in activating the RSTOSC_LFINTOSC.

    Far more serious is that with these settings "#config MCLRE_INTMCLR, WDTE_OFF, WDTE_SWDTEN, BOREN_OFF, RSTOSC_HFINTOSC_1MHZ, FEXTOSC_OFF" only some of the controllers start properly, most of them do not work after powering on again. If I reduce the settings to "#config MCLRE_INTMCLR, RSTOSC_HFINTOSC_1MHZ", it seems to work...

    Can someone explain me the structure of the "16f15224.dat" file? I am irritated that according to my understanding e.g. the address ",2,16383" is accessed several times? Shouldn't these be different addresses or do I understand something wrong?

    MCLRE_EXTMCLR,2,16383
    PWRTS_PWRT_OFF,2,16383
    WDTE_ON,2,16383
    BOREN_ON,2,16383
    BORV_LO,2,16383
    PPS1WAY_ON,2,16383
    STVREN_ON,2,16383

    THANKS!

    Frank

     
  • William Roth

    William Roth - 2022-12-08

    Hi Frank,

    You are understanding the chip datafile incorrectly. For example "2, 16383"

    The "2" represents Config Word 2 at address 0x8008 ( see datasheet for addresses)
    16383 is the bit mask ( Not an address) for the bits in ConfigWord2. There are 14 bits in a 16F Config Word, therefore when all are 1's the dec val is 16383
    Decimal 16383 = 111111 11111111 Binary where a specific function is enabled with a "0"
    and disabled with a "1".

    So for example STVREN_ON,2,16383 means that this function is at address 0x8008 and since the bit is a 1 ( all bits are 1 at reset) ... STRVEN_ON is disabled.

    It seems to me that when you change MCLRE from External to Internal and they all start working, that it is likely that the MCLRE Pin may be missing a pull up resistor. This is Pin 4 on the 16F15224.

    Anytime that MCLRE = ON/External or LVP = ON there must be a pullup resistor on the MCLRE Pin

    As far as operation at 31K (LFINTOSC) I do not think that this is supported on this series of chip (Yet?)

    See attachment from PicInfo tool. This shows a min of 1 Mhz.

    William

     

    Last edit: William Roth 2022-12-08
  • Frank

    Frank - 2022-12-09

    Hi William,
    thank you very much for your explanation!
    Can you please explain where I can see that the CONFIG2 address is 0x8008? I can't find this address neither in the DAT file nor in the XML file...

    As far as operation at 31K (LFINTOSC) I do not think that this is supported on this series of chip (Yet?)

    The datasheet says:

    Clocking Structure
    • High-Precision Internal Oscillator Block (HFINTOSC):
    – Selectable frequencies up to 32 MHz
    – ±2% at calibration
    • Internal 31 kHz Oscillator (LFINTOSC)
    • External High-Frequency Clock Input:
    – Two External Clock (EC) Power modes

    So actually it should be possible...

    It seems to me that when you change MCLRE from External to Internal and they all start working, that it is likely that the MCLRE Pin may be missing a pull up resistor. This is Pin 4 on the 16F15224.
    Anytime that MCLRE = ON/External or LVP = ON there must be a pullup resistor on the MCLRE Pin

    I tried a resistor on MCLRE with no success!
    With "#config MCLRE_INTMCLR, RSTOSC_HFINTOSC_1MHZ" the circuit now works correctly (with no resistor) - but I do not know why!?!

    I had used the PIC16F15323 before - but unfortunately it is not available at the moment! :-(

    Frank

     
  • Anobium

    Anobium - 2022-12-09

    Frank - thanks for reporting. An oversight.

    31K support - I have just added. Get DEV build 1203 is that the corrected DAT files for the 16F152xx chip family. To get the DEV build start GC Studio, change the Channel to DEV. Or, I have attached the one DAT you need to this post - put in your CHIPDATA folder.


    I have posted a new DAT at 09:38 London Time 9/12/2022

    Evan

     

    Last edit: Anobium 2022-12-09
  • Frank

    Frank - 2022-12-09

    Hi Evan,

    thank you very much!!!

    Frank

     
    • Anobium

      Anobium - 2022-12-09

      A quote from Old Sage Bill Roth
      The ASM looks correct but there is nothing like real testing on real silicon.

      So, do test and let us know of any issues.

       
  • William Roth

    William Roth - 2022-12-09

    The address of the configuration data can be found in the Datasheet on Page 22/ 8.1 as well as in in Table 15.1 . NVM Organization and Access Information on page 107.

    Remember at 31K system clock, the timing accuracy will not be perfect. There can be no microsecond delays. So use milliseconds instead.

    One instruction take ~30 us at a system clock of 32,768 Hz

    1,000,000 / 32,768 = 30 us

    William

     

    Last edit: William Roth 2022-12-09
  • William Roth

    William Roth - 2022-12-09

    For Frank,

    Attached is a small program to test the operation of the 16F15224. It works ok here on a real chjp.
    Make sure you have a 10K resistor from Pin4 to Vdd (5V)

    William

     

    Last edit: William Roth 2022-12-09
    • Anobium

      Anobium - 2022-12-10

      The config statements could be rationalised as the compiler will set these automatically. It is still good to have them for clarity.

      The RSTOSC = LFINTOSC is extracted from the new DAT file. And, FEXTOSC = OFF is a generic default.

      #Config RSTOSC = LFINTOSC
      #Config FEXTOSC = OFF
      
       
  • Frank

    Frank - 2022-12-12

    For Frank,

    Attached is a small program to test the operation of the 16F15224. It works ok here on a real chjp.
    Make sure you have a 10K resistor from Pin4 to Vdd (5V)

    William

    Hi William,
    your program works as it should (with the new DAT file), but also without pullup with a floating MCLR...

    Frank

     
  • William Roth

    William Roth - 2022-12-12

    @Frank

    It may seem to work OK without the Pullup. But if you leave it floating the chip can/will intermittently reset.

    Don't do it.

    Added: There is an internal weak pullup that is enabled when MCLRE = On. This prevents the pin from actually "floating". There is also an internal 'noise filter' so that short pulses are ignored. However, the internal weak pullup may not be sufficient to hold the chip in reset in noisy environments eg, servos, motors , etc. Therefore an external pullup is highly recommended.

     

    Last edit: William Roth 2022-12-12
  • David Stephenson

    With regard to the MCLR pin. Why is not setting MCLR=Off not sufficient?

     
    • William Roth

      William Roth - 2022-12-12

      It can be sufficient if no external reset capability is necessary or wanted, especially in low pin count devices where every pin is needed for analog or digital purposes.

      However, in many applications, and in the development environment, an external reset switch/circuit may be prudent or even necessary. Otherwise there would no need for MCLRE and it could be eliminated altogether.

       
  • David Stephenson

    I asked the question because I often get problems with low current applications. I have found that setting MCLR as an input and connecting it to ground reduces SLEEP current (even when MCLR=off has been selected). I have also used it as a SDI pin for SPI (when I ran out of other pins). I prefer to use the power down reset rather than MCLR.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.