IOC flag triggered when PIC is unplugged...?


+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878

    Question IOC flag triggered when PIC is unplugged...?

    16F18877

    Any idea why it would do that?

    The PIC is running normally, and then the IOC flags get set when I pull the USB cable on the MeLabs programmer (or unplug the header).

    I know my encoders can jitter, but I'm not even touching them.


    EDIT: My configs for brown out in case it helps:

    Code:
    _BOREN_ON & _BORV_LO
    Last edited by Demon; - 21st September 2024 at 05:13.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,470


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    i guess it begs the questions
    what ioc flags were triggered ?
    what pins had any ioc functions active?
    Warning I'm not a teacher

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Code:
    IOC_COM1_Swap_flag          var IOCAF.4
    IOC_COM2_Swap_flag          var IOCCF.1
    IOC_NAV1_Swap_flag          var IOCBF.5
    IOC_NAV2_Swap_flag          var IOCBF.2
    These, at random.

    Only IOC was used, no other peripherals used on these pins.

    I tried external pull-ups just now, in case the internal were just borderline, but that didn't make a difference.

    EDIT: Using this wiring:

    Name:  Switch debounce.jpg
Views: 246
Size:  26.8 KB
    Last edited by Demon; - 21st September 2024 at 16:15.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    These are pushbuttons, not rotary encoders with wonky shafts that can jitter whenever the cat farts.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    I'm certain it has something to do with voltage levels as the PIC loses power.

    IOC flags are randomly triggered when VDD is cut with a switch, but not on MCLR.

    Values are READ from DATA at PIC start-up. IOC flags on pushbuttons are used to swap values left to right, then WRITE back to memory.* By the end of the video, all values have swapped places without pushing any buttons.

    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,470


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Ceramic bypass/decoupling capacitors are often better .

    IOC flags on pushbuttons are used to swap values left to right, then WRITE back to memory
    a particularly bad practice, you should always check that it was an actual keypress [ in that was held for a definitive time] before actioning it

    key activity should be ignored until power is stable
    Warning I'm not a teacher

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Quote Originally Posted by richard View Post
    Ceramic bypass/decoupling capacitors are often better ...
    I have 0.1uF on VDD/VSS pins, 0.1uF on the switch input pins and 0.01uF on the encoder input pins; all ceramic caps.


    Quote Originally Posted by richard View Post
    ...a particularly bad practice, you should always check that it was an actual keypress [ in that was held for a definitive time] before actioning it...
    That's what the IOC flag was used for; to check if a button was activated. If I'm going to have to check if a key has been pressed, IOC is of no advantage to me. I didn't understand why you guys were not in favour of using IOC for this, but now I'm understanding a lot better why it wasn't good idea.

    I've already gutted the IOC code and I'm checking the pins for change in value. Those 4 SWAP buttons were the last ones, and then I noticed things were going wacky with my stored data.


    Quote Originally Posted by richard View Post
    ... key activity should be ignored until power is stable
    I always have at least PAUSEUS 200 at program startup. I have no idea how to check if power is stable on shut-down.


    I've given up on the 16F18877; I had switched to these for IOC, internal pull-ups and Schmitt Trigger features. But they're much more finicky than a 16F1937 with external pull-ups, 74HC14 ICs and just polling the pins in MainLoop.

    The 16F1937 is like a tank; less fancy but it keeps on trucking.
    Last edited by Demon; - 22nd September 2024 at 03:32.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,470


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    That's what the IOC flag was used for; to check if a button was activated.
    That is a false assumption, all the IOC flag says is that a edge was detected, you need way more info to determine if it was a valid key press, at a minimum you need to know if its still "active" and if it was "active" for a reasonable time. no simple hw debounce solution will do all the work

    don't forget a 0.000000025S [thats 25nS ] pulse can trigger an ioc event , would you call that a key press
    how about 25uS what about 1mS , for my money i would ignore anything less than 50mS
    glacially slow for a Pic@32MHz

    ps , switches on long leads and breadboards are potentially difficult cases also
    Last edited by richard; - 22nd September 2024 at 04:01.
    Warning I'm not a teacher

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Quote Originally Posted by richard View Post
    That is a false assumption, all the IOC flag says is that a edge was detected, ...
    I know that now.


    Quote Originally Posted by richard View Post
    ... no simple hw debounce solution will do all the work...
    The 74HC14 with Bourns' debounce was doing very well. I'm rewiring that back in now to redo testing.


    Quote Originally Posted by richard View Post
    ... for my money i would ignore anything less than 50mS...
    I'll post results when I have everything back up and running. It was surprisingly stable before I migrated to a 16F18877.


    Quote Originally Posted by richard View Post
    ... switches on long leads and breadboards are potentially difficult cases also
    Switches and encoders are all mounted on headers, same for power jack, USB connector and 7805.

    The only leads for switches will be from 74HC14 to PIC, and I keep those on 2 breadboard area maximum. The only PIC with long leads is for the LCDs.

    The USART leads (in white) will branch out from the USB PIC out to the SW and ENC PICs (the END lead is 5in straight line, so about 6in when strung out).

    Name:  Breadboard.jpg
Views: 214
Size:  572.3 KB
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,470


    Did you find this post helpful? Yes | No

    Smile Re: IOC flag triggered when PIC is unplugged...?

    It was surprisingly stable before I migrated to a 16F18877.
    to get away from all the needless 7416 chips plus the flexibility of pps as a bonus
    Warning I'm not a teacher

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Quote Originally Posted by richard View Post
    to get away from all the needless 7416 chips plus the flexibility of pps as a bonus
    That was my original goal, to reduce cost, complexity and real estate.

    I gotta admit, PPS, was a neat bonus. I was truly impressed with the 16F18877.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,947


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    I would not give up on the 18877 chip. Sometimes the view seems great but has pitfalls and all you need is to sleep on this. Next day will come the aha moment!

    Ioannis

  13. #13
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Quote Originally Posted by Ioannis View Post
    I would not give up on the 18877 chip. Sometimes the view seems great but has pitfalls and all you need is to sleep on this. Next day will come the aha moment!

    Ioannis
    Yeah, I'm giving it another shot cause I need a PIC with ADCON. I just find it so finicky, so many registers to set JUST RIGHT.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,878


    Did you find this post helpful? Yes | No

    Default Re: IOC flag triggered when PIC is unplugged...?

    Ioannis, guess what...

    https://www.picbasic.co.uk/forum/sho...-on-input-pins

    I found the root of most of my problems with this PIC.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Replies: 9
    Last Post: - 1st November 2016, 14:37
  2. DT_INTS-14.bas Reset Flag
    By Larryd in forum Serial
    Replies: 2
    Last Post: - 8th April 2013, 22:44
  3. Replies: 1
    Last Post: - 12th May 2012, 12:37
  4. How to know what pin triggered an interrupt?
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 13th October 2008, 07:29
  5. DS18B20 Busy Flag
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th November 2006, 13:21

Members who have read this thread : 7

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

Posting Permissions

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