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

play songs on a peizo buzzer?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Dec 22, 2005 7:58 am     Reply with quote

Try:

X0R(portc, 0b000 0011);

Now it won't change any of the other bits. If portc is mapped to the actual port the XOR itself will change the port pins without affecting the tristate register.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 22, 2005 10:57 am     Reply with quote

Christophe wrote:
So,

that would be

output_high(C0);
output_low(C1);
X0R(portc, 1111 1111);

output(portC);

the problem is that all port C pins are changing and becoming outputs. I don't want that because they are used for other purposes.


This function is causing the problem
output(portC);

you will need to specify fast_io to prevent this and handle the tris register yourself.
mcafzap



Joined: 07 Sep 2003
Posts: 46
Location: Manchester, UK

View user's profile Send private message

PostPosted: Fri Dec 23, 2005 7:11 am     Reply with quote

To avoid RMW problems on the I/O ports, here is my buzzer routine:
Code:
void shortbeep(void)
{
int8 t;
t = Port_A & 0xCF;
for(j=0; j<=250;j++)
   {
   Port_A = t | 0x20;
   Delay_Us(120);
   Port_A = t | 0x10;
   Delay_Us(110);
   }
Port_A = t;
}


Steve
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
Page 2 of 2

 
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