Created Wed, 22 Jun 2011 03:24:55 +0000 by jRobert
Wed, 22 Jun 2011 03:24:55 +0000
Can anyone tell me how to access the port registers on the chipKit boards? Specifically RE0-RE7 pins. I've been digging and know they're called TRIS and Lat registers and think I can figure out the logic. I just can't figure out how to get control of them.
Wed, 22 Jun 2011 04:29:38 +0000
This'll blink the whole port E. Is that what you want?
void setup() {
TRISE = 0;
}
void loop() {
LATEINV = 0xff;
delay(30);
}
Wed, 22 Jun 2011 04:50:54 +0000
This'll blink the whole port E. Is that what you want?
void setup() {
TRISE = 0;
}
void loop() {
LATEINV = 0xff;
delay(30);
}
Don't you also need:
LATEINV = 0;
delay(30);
just after the delay(30); you already have there? You need to set the port back to all 0 and do another delay(30) to provide the sought after blinking port. :)
8-Dale
Wed, 22 Jun 2011 04:51:47 +0000
It's not
LATEINV ^= 0xff;
Alan KM6VV
Wed, 22 Jun 2011 04:58:11 +0000
LATEINV inverts all bits in LATE which are written as 1, so LATEINV=0xff inverts all the bits of LATE -- no other code is needed to "blink".
For each register xxx, there is also an xxxSET, xxxCLR, and xxxINV... Writing a 1 to the xxxSET register is like doing an |= to the xxx register... Writing a 1 to the xxxCLR register is like doing an &=~ to the xxx register. And, of course, writing a 1 to the xxxINV register is like doing an ^= to the xxx register.
The purpose of the xxxSET, xxxCLR, and xxxINV registers is to replace a read-modify-write operation with a simple posted write.
Also, if you're looking for all the register descriptions, just search for p32mx320f128h.h in your mpide directory -- that's the header used for the Uno32.
-- Rich
Wed, 22 Jun 2011 05:06:12 +0000
Well now, I sit corrected! :) Thanks guys! :D I'm learning new stuff here almost every day.
8-Dale
Wed, 22 Jun 2011 05:45:13 +0000
That's quite a set of commands! Thanks for the explanation Rich.
So we no longer have to worry about a read-modify-write instruction being interrupted? Seems like that was a problem at one time...
Alan KM6VV
LATEINV inverts all bits in LATE which are written as 1, so LATEINV=0xff inverts all the bits of LATE -- no other code is needed to "blink". For each register xxx, there is also an xxxSET, xxxCLR, and xxxINV... Writing a 1 to the xxxSET register is like doing an |= to the xxx register... Writing a 1 to the xxxCLR register is like doing an &=~ to the xxx register. And, of course, writing a 1 to the xxxINV register is like doing an ^= to the xxx register. The purpose of the xxxSET, xxxCLR, and xxxINV registers is to replace a read-modify-write operation with a simple posted write. Also, if you're looking for all the register descriptions, just search for p32mx320f128h.h in your mpide directory -- that's the header used for the Uno32. -- Rich
Wed, 22 Jun 2011 06:21:58 +0000
Thanks guys. I'm using RE as bidirectional parallel bus to talk to a 4DG 32PT-GFX so I can use the touchscreen for input. Project is motion controller for my video cameras. Again thanks for your quick response.
Mon, 27 Jun 2011 16:09:47 +0000
Thanks guys. I'm using RE as bidirectional parallel bus to talk to a 4DG 32PT-GFX so I can use the touchscreen for input. Project is motion controller for my video cameras. Again thanks for your quick response.
PORTE is the data bus for the Parallel Master Port. You should download the Parallel Master Port section of the PIC32 Family Reference Manual from the Microchip web site. You might find it useful for your project. The Parallel Master Port can be used to drive a wide variety of multiplexed and non-multiplexed parallel bus interfaces. This can significantly increase transfer rates in some cases.
Gene Apperson Digilent