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 support@ccsinfo.com

PIC16F628A : interrupt on change + UART operation = Bad?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sparkkey



Joined: 02 Apr 2012
Posts: 2

View user's profile Send private message

PIC16F628A : interrupt on change + UART operation = Bad?
PostPosted: Mon Apr 02, 2012 5:06 pm     Reply with quote

The preface:

I would like to use the interrupt on change (IOC) feature on a PIC16F628A to take in quadrature encoder pulses, as well as use the integrated UART to send and receive data to an external device. Both functions are on PORTB and the spec sheet warns that "polling" PORTB can reset the IOC interrupt flag. I will be receiving encoder pulses on the IOC pins, and I need to send and receive data via the UART port at the same time, seamlessly. My CCS compiler is a few years old, but seems to work well in general.

The question:

Will using the integrated UART peripheral on the 16F628A interfere with the Interrupt-On-Change feature on portb? There will be constant pulses coming in on PORTB (pins 6 and 7) and I cannot afford to miss a single encoder pulse, which I was planning on handling in the IOC interrupt handler. If the CCS HARDWARE UART routines poll PortB or cause the IOC interrupt bit to get reset before being handled, I will have to find another solution.

Thanks!

-SP
Ttelmah



Joined: 11 Mar 2010
Posts: 19326

View user's profile Send private message

PostPosted: Tue Apr 03, 2012 2:48 am     Reply with quote

'Polling' the port, means reading it. The hardware UART routines, don't read the _port_, they only read the _UART_. Microchip (this is nothing to do with the compiler, but the _hardware_), are 'smart enough', to know that if the put a peripheral/feature on a port, it try to should avoid the pins used by other peripherals/features. So 'IOC' (Interrupt on change), is on ports B:4 to 7, and not affected by the UART pins (B:1, and B:2). The same applies to the CCP on B:3.
Provided you make sure you use the hardware UART pins, and that the compiler is setup to use the hardware (a software UART on - say - B0, _would_ read the port), both features should work for you.
You don't say your compiler version, but 'late' V3 compilers (3.249 for example), are excellent, and except for a few new features, work 99% as well as the current offerings for such chips.

Best Wsihes
sparkkey



Joined: 02 Apr 2012
Posts: 2

View user's profile Send private message

PostPosted: Tue Apr 03, 2012 9:53 am     Reply with quote

I appreciate the feedback. I was thinking along the same lines but wanted feedback before I moved down this path. I will breadboard it and do some tests to ensure it behaves as expected. Thanks again!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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