MOD5282 GPIO for inputs on Port J (J1-5/6/7 Pins)
Posted: Sat Jan 21, 2012 12:47 pm
Using the MOD5282 on my own board, initializing for GPIO on Port J per MOD5282 GPIO Configuration App Note, with push buttons with pullups on J1-5/6/7 pins. Pushing button definitely brings voltage at pins J1-5/6/7 low, but reading Port J results in a fixed value of 14.
What is missing? Code snippet:
//J1-5,6,7 as input
// Port J Pin Assignment Register. Set bit to 0 for GPIO, or 1
// for primary function (5282UM table 26-12). The following
// code example sets the CS pins to GPIO without changing the
// configuration of the BSx pins (i.e upper 4 bits and bit
// 0 are unchanged):
sim.gpio.pjpar &= 0xf1;
// Port J Data Direction Register. Set bit to 1 for output, or
// 0 for input.
sim.gpio.ddrj &= 0xf1; // Zero bits 1,2,3 for input set, leave other alone
while(1)
{
BYTE value_j = sim.gpio.portj;
iprintf("Portj is %d\r\n",value_j);
}
This forever just prints 14, regardless of pushing the buttons to bring low J1-5/6/7
Any ideas?
What is missing? Code snippet:
//J1-5,6,7 as input
// Port J Pin Assignment Register. Set bit to 0 for GPIO, or 1
// for primary function (5282UM table 26-12). The following
// code example sets the CS pins to GPIO without changing the
// configuration of the BSx pins (i.e upper 4 bits and bit
// 0 are unchanged):
sim.gpio.pjpar &= 0xf1;
// Port J Data Direction Register. Set bit to 1 for output, or
// 0 for input.
sim.gpio.ddrj &= 0xf1; // Zero bits 1,2,3 for input set, leave other alone
while(1)
{
BYTE value_j = sim.gpio.portj;
iprintf("Portj is %d\r\n",value_j);
}
This forever just prints 14, regardless of pushing the buttons to bring low J1-5/6/7
Any ideas?