![]() |
Addressing I/O in Sections
I was wondering if it is possible to address sections of the I/O of the RC all at once. For example, I have a parallel LCD which uses 8 I/O lines for data. Thus, I want 8 pins of the I/O to be assigned either high or low at the same time instead of addressing them individually.
Code:
LCD_port = 5;Is there anyway to do this that I am unaware of? Similarly, can I access just the upper and lower half of an unsigned int somehow? Please pardon me if these sound like n00b questions, as I am certainly a beginner in the C language. |
Re: Addressing I/O in Sections
Just a quick disclaimer - I'm not a programmer.
Are you looking to do it for ease or because you don't want the delay? Have you tried it just doing them one-by-one? The digital IO of the PIC changes so quickly that I can't see it really being an issue doing them one by one. Otherwise, I'm pretty sure it would not be possible to do, as there are not 8 digital out's all on the same 8-bit port, except relay outputs, all 8 fowards are on port E and all 8 reverse's are on port D. If you used the relay outputs, you could just assign to the output byte for the respectable port (i think). If you just wanted ease, couldn't you write a function to split up your char input and assign it to the correct digital out bits? |
Re: Addressing I/O in Sections
I fully agree with Brian's assessment. Here's a little primer on PICs:
All the I/O lines are grouped into "ports". Each port can be viewed as a memory address. Each line corresponds to a bit in the char stored at the address. If you change whatever is at the address, you change the respective lines. If you look at the block of code in ifi_aliases.h starting at line 109, you can see which digital I/Os correspond to which ports on the processor. You'll notice that the biggest set of digital I/Os is only 7 bits wide. As Brian pointed out, if you really need all 8 bits, it shouldn't be too hard to just write a function to handle each bit individually. Maybe something along the lines of Code:
digital_io_01 = my_char >> 7; |
Re: Addressing I/O in Sections
First off, I agree with Briand and sciguy. :)
However... theoretically, it may be possible to do what you want. There are a couple of things which have to be true: (and may not be, I've never tried doing this.)
|
Re: Addressing I/O in Sections
I'm assuming you are using an HD44780 compatible LCD. You don't need 8 pins that can be adressed as a group, only 4 if you use the LCD in 4-bit mode. All you have to do is setup the IO correctly and write to to the appropriate port register. Really, you don't actually need to have them written to at once since data is read in by the LCD only when you tell it to. I have controlled an HD44780 LCD using toggle switches before. Obviously, timing does not matter at all.
You will of course still need 3 more pins for E, R/W, and RS. |
Re: Addressing I/O in Sections
I think he's more going for ease of use.. in which case:
#define LCD_Port digital_io_01 = digital_io_02 = digital_io_03 ...etc |
Re: Addressing I/O in Sections
Quote:
-Kevin |
Re: Addressing I/O in Sections
Quote:
|
| All times are GMT -5. The time now is 04:31. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi