C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28384
Number of posts: 94256

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need help about embedded C programming Posted by maheshbest on 29 Jul 2009 at 10:05 AM
Hi all,
I need some info about below program for embedded C,

void main (void ){
unsigned char mybyte;
P1=0xFF; // make port input enabled
while (1){
mybyte=P1;
MSDelay(500);
P2=mybyte; // buzzer signal
}
}

In above program, 0xFF signal is sent to port 1 for enabling it for input.
Now if, i am passing 0xFF as an input signal to port 1 then the same data will get assigned to mybyte and after that it will be sent to P2.
Now my question is, will P2 become input enabled or it will just send that data to output device?
How does the port differentiate between output signal and latch signal?

Regards,
Mahesh Kedari
Report
Re: Need help about embedded C programming Posted by Lundin on 31 Jul 2009 at 7:23 AM
Typically, microcontrollers have at least 2 registers per port: one for data direction (input/output) and one for the actual data.

How your particular microcontroller works, I have no idea. Might be wise posting which one it is if you expect better replies...



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.