SCHEMATIC 2. To reveal this
Pmod portal's alter ego, a wee
bit of Microchip to Motorola
interpretation is in order.
stack. The idea is to match up logical I/O definitions in the
TCP/IP stack with the physical I/O of the 32MX7. Let’s start
with mapping the Cerebot’s four user LEDs which are
physically attached to RG12 through RG15:
// TCP/IP Stack Original LED Configuration
#define LED0_TRIS (TRISAbits.TRISA0)
// Ref D3
(LATAbits.LATA0)
(TRISAbits.TRISA1)
// Ref D4
(LATAbits.LATA1)
(TRISAbits.TRISA2)
// Ref D5
(LATAbits.LATA2)
(TRISAbits.TRISA3)
// Ref D6
(LATAbits.LATA3)
(*((volatile unsigned
char*)(&LATA)))
#define LED_PUT(a) (*((volatile unsigned
char*)(&LATA)) = (a))
#define LED0_IO
#define LED1_TRIS
#define LED1_IO
#define LED2_TRIS
#define LED2_IO
#define LED3_TRIS
#define LED3_IO
#define LED_GET()
// Cerebot 32MX7 LED Configuration
#define LED0_TRIS (TRISGbits.TRISG12)
// Ref D3
(LATGbits.LATG12)
(TRISGbits.TRISG13)
// Ref D4
(LATGbits.LATG13)
(TRISGbits.TRISG14)
// Ref D5
(LATGbits.LATG14)
(TRISGbits.TRISG15)
// Ref D6
(LATGbits.LATG15)
(*((volatile unsigned
char*)(&LATG)))
#define LED_PUT(a) (*((volatile unsigned
char*)(&LATG)) = (a))
#define LED0_IO
#define LED1_TRIS
#define LED1_IO
#define LED2_TRIS
#define LED2_IO
#define LED3_TRIS
#define LED3_IO
#define LED_GET()
I think you get the idea. So, I’ll not show you the
original TCP/IP stack momentary push button assignments:
// Cerebot 32MX7 Momentary Push Buttons
#define BUTTON0_TRIS (TRISGbits.TRISG6)
// Ref S4
#define BUTTON0_IO (PORTGbits.RG6)
#define BUTTON1_TRIS (TRISGbits.TRISG7)
// Ref S5
#define BUTTON1_IO (PORTGbits.RG7)
#define BUTTON2_TRIS (TRISDbits.TRISD13)
// Ref S6
#define BUTTON2_IO (PORTDbits.RD13)
Defining the 32MX7’s LEDs and pushbuttons to the
TCP/IP stack may seem trivial right now. However, when it
gets thick and things aren’t working as you would like them
to those LEDs and pushbuttons become welcomed
debugging tools.
So far, all of the TCP/IP stack redefinitions occur in the
HardwareProfile.h file associated with the project. I’ve
chosen to use the TCP/IP stack’s 32-bit TCP/IP Demo App,
which is based on the Explorer 16 development platform’s
hardware.
The Pmod WiFi SPI I/O assignments are also part of the
TCP/IP stack’s HardwareProfile.h code. Here are the new
Pmod WiFi I/O definitions:
// MRF24WB0M in SPI1 slot
#define WF_CS_TRIS
#define WF_CS_IO
#define WF_SDI_TRIS
#define WF_SCK_TRIS
#define WF_SDO_TRIS
#define WF_RESET_TRIS
#define WF_RESET_IO
(TRISDbits.TRISD9)
(LATDbits.LATD9)
(TRISCbits.TRISC4)
(TRISDbits.TRISD10)
(TRISDbits.TRISD0)
(TRISDbits.TRISD2)
(LATDbits.LATD2)
Sources
Digilent
Cerebot 32MX7
PmodWiFi
PmodRS232
www.digilentinc.com
Microchip
Microchip Application Libraries
www.microchip.com
SERVO 07.2011 43