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

Timer ISRs can break RS232

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







Timer ISRs can break RS232
PostPosted: Fri Sep 26, 2008 12:33 am     Reply with quote

I had to add pwm modulation to led drivers
that were not on the hardware pwm outputs on a
11Mhz 16F887. I first added PWM bit banging to
the control loop, but it flickered when processing commands.
I had used timer 1 for something but it was too
slow to pwm. When I tried to use timer 0 or 2,
by copying the ISR code (and renaming the functions)
I broke the RS 232 interface. Whether or not I
enabled the interrupts didn't matter. WTF?

I think it has to do with the way the CCS compiler handles
interrupts, when more than one ISR accesses a global
variable. When I gutted the second ISR of any code
it worked fine, and it worked fine when I removed the original
ISR. But more than one ISR messing with the same global
hosed my RS232!! Took me an afternoon to find this.

Still this compiler has saved so much effort its worth working with
despite its warts.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Sep 26, 2008 3:03 am     Reply with quote

Can you show a minimal code example that produces the problem?
Ttelmah
Guest







PostPosted: Sat Sep 27, 2008 2:29 am     Reply with quote

Agree. You need to post and example.

However there is nothing in the 'CCS compiler handles
interrupts', that will break the RS232. Things that may/will:

Interrupt handlers that take too long. This is the 'classic'...
Not having 'errors' in your RS232 declaration.
Having 'delay' statements in your interrupt handler.

A search here, will find lots (hundreds) of posts about how interrupt handling needs to be done to work reliably. The data that 'stripping' the handler down, makes it work, suggests that the first is the problem.

Best Wishes
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