MCF_GPIO_DDRNQ = MCF_GPIO_DDRNQ_DDRNQ7; MCF_GPIO_PNQPAR = 0; /* Pins 1-6 configured as GPIO inputs Pin NQ7 configured as GPIO output Pin NQ6 as input Pin NQ5 as input Pin NQ4 as input Pin NQ3 as input Pin NQ2 as input Pin NQ1 as input */ MCF_EPORT_EPPAR = 0; MCF_EPORT_EPDDR = MCF_EPORT_EPDDR_EPDD7; MCF_EPORT_EPIER = 0; MCF_GPIO_PORTNQ = 0;
/* MACROS to set, clear PORTNQ7 */#define NQ_BIT7_HIGH MCF_GPIO_SETNQ = MCF_GPIO_SETNQ_SETNQ7 #define NQ_BIT7_LOW MCF_GPIO_CLRNQ = 0x7F;/* MACROS to read PORTNQ bits 1-6 */#define READ_PORTNQ MCF_GPIO_SETNQ &= 0x7E#define PORTNQ_BIT1 0x02#define PORTNQ_BIT2 0x04#define PORTNQ_BIT3 0x08#define PORTNQ_BIT4 0x10#define PORTNQ_BIT5 0x20#define PORTNQ_BIT6 0x40
#include <stdio.h>#include "common.h"int main (){ int i; int Switch1 = 0, Switch2 = 0; MCF_GPIO_PORTTC = 0x0; while (1) { Switch1 = READ_PORTNQ; Switch1 &= MCF_GPIO_PORTNQ_PORTNQ5; Switch2 = READ_PORTNQ; Switch2 &= MCF_GPIO_PORTNQ_PORTNQ1; if (Switch1 == 0x0) MCF_GPIO_PORTTC = 0x1; else { if (Switch2 == 0x0) MCF_GPIO_PORTTC = 0x2; else MCF_GPIO_PORTTC = 0x0; } }}
static void init_eport (void){ // Pins 1-7 configured as GPIO inputs MCF_EPORT_EPPAR = 0; MCF_EPORT_EPDDR = 0; MCF_EPORT_EPIER = 0;}static void init_pin_assignments (void){ // Pin assignments for port NQ // Pins are all used for EdgePort GPIO/IRQ MCF_GPIO_DDRNQ = 0; MCF_GPIO_PNQPAR = 0; MCF_GPIO_PORTNQ = 0;.../* Bit definitions and macros for MCF_GPIO_PORTNQ */#define NQ_BIT7_HIGH MCF_GPIO_SETNQ = 0x80;#define READ_PORTNQ MCF_GPIO_SETNQ &= 0x7E;#define MCF_GPIO_PORTNQ_PORTNQ1 (0x2)#define MCF_GPIO_PORTNQ_PORTNQ2 (0x4)#define MCF_GPIO_PORTNQ_PORTNQ3 (0x8)#define MCF_GPIO_PORTNQ_PORTNQ4 (0x10)#define MCF_GPIO_PORTNQ_PORTNQ5 (0x20)#define MCF_GPIO_PORTNQ_PORTNQ6 (0x40)#define MCF_GPIO_PORTNQ_PORTNQ7 (0x80)...
d = MCF_GPIO_PORTNQ;
/* * File: main.c * Purpose: sample program * */#include <stdio.h>#include "common.h"int main (){ while (1) { if (MCF_GPIO_PORTNQ == MCF_GPIO_PORTNQ_PORTNQ5) MCF_GPIO_PORTTC = 0x1; else MCF_GPIO_PORTTC = 0x2; }}
MCF_GPIO_PORTNQ_PORTNQ5 = 0x20
J2MEJediMaster wrote:
first, program the the port to be GPIO
#define MCF_GPIO_PORTNQ (*(vuint8 *)(&__IPSBAR[0x100008]))
I don't undersand the meaning of "Program to GPIO lines to SW2" but i think that the problem is that the SW1 is joined to IRQ5 interrupt and i don't undestand why the 8 bit register PORTNQ doesn't manage to bring the "1" in the 6th bit when i push the SW1 button:
J2MEJediMaster wrote:
... and second, program to GPIO lines to SW2 and SW2 to be configured as inputs...
---Tom