CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24FJ64GA004 - detecting I2C stop bit (P) inside an ISR
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Dec 04, 2020 12:04 pm     Reply with quote

Ttelmah wrote:
Er. Level=7, is the highest priority. Not what is wanted.....
Level=1.


I haven’t even looked at that yet. I just assumed "there must be a reason it says 7" Smile

We use a ton of timers (most use every timer available) and I2C as the only interrupts.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Dec 16, 2020 11:16 am     Reply with quote

Just curious... I based my polled I2C routines on existing examples. As such, after each byte, I poll looking for either a stop bit or the next incoming ISR flag:

Code:

        // Wait for either a stop bit, or another incoming data byte.
        while ((P == 0) && (I2C_SYSTEM_BUS_IRQ_PENDING_BIT == 0));

        if (P != 0)
        {
            //DEBUG_PRINTF ("P");
            break;
        }


I recently saw code that polled the RBF (receive buffer full) status instead of the IRQ pending bit.

Is there an advantage to one method over the other? I just tested the RBF method in my code and it seems to also work fine... Block until there is either another byte to read, or a stop bit has been seen.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19495

View user's profile Send private message

PostPosted: Thu Dec 17, 2020 1:22 am     Reply with quote

Some chips have errata on one. On these it is recommended to use RBF
rather than the interrupt. Also, though your chip doesn't support interrupt
on start/stop, a lot do. On these if you checked the interrupt, it might be
one of these, not the data....
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Nov 11, 2024 8:44 am     Reply with quote

allenhuffman wrote:
I went down the "I2C bus reset" rabbit hole a year ago, seeing it mentioned and documented with ways to un-stick the lines. But, sadly, FTDI provides no way to do this from their Windows driver/API so we could never implement it :(


I just wanted to add, since this was posted FTDI finally DID add a Bus Reset feature to its Windows driver.

Sadly, nothing we have tried (exhausting all the suggestions from FTDI) works at un-freezing a system when we get the real lockup. The FTDI chip seems unreliable when it gets messed up, and none of their Reset, Cycle Port, re-init routines will un-stick it. We have to power cycle the Windows computer when this happens ;-)

Windows is not an optimal solution for something you want to run reliably for months at a time ;-)
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group