EmbeddedRelated.com
Forums

AT91SAM9263 EK - B programming

Started by sudhan_ssn March 21, 2009
#include "at91sam9263.h"

void delay();
void pulsedelay();
#define LED_A 0X180;
#define LED_B 0X20000000;
#define A1 0x00000001; /* To select pin no. 4 of J25 */
#define B1 0x00000002; /* To select pin no. 3 of J25 */
#define C1 0x00000004; /* To select pin no. 6 of J25 */
#define D1 0x00000008; /* To select pin no. 5 of J25 */

int j;

void main()
{
AT91C_BASE_PIOD->PIO_OER=0x0000000f;
/* Enable PIO control on the pins*/
// AT91C_BASE_PIOB->PIO_PER = LED_A;
// AT91C_BASE_PIOC->PIO_PER = 0X20000010; //Enable the PC4 for switch & PC29 for LED.

/* Configure the pins as outputs */
// AT91C_BASE_PIOB->PIO_OER = LED_A;
// AT91C_BASE_PIOC->PIO_OER = LED_B;
//AT91C_BASE_PIOC->PIO_ODR = 0x10; //Enable the PC4 as a input.

// j=AT91C_BASE_PIOC->PIO_OSR; //Check the PIO Output Status Register.

/* Disable pull-ups */ //Disable the pull-up for the PB7, PB8 & PC29th pin.
// AT91C_BASE_PIOB->PIO_PPUDR = LED_A;
// AT91C_BASE_PIOC->PIO_PPUDR = LED_B;
while(1)
{
/* Turn LED on */
// AT91C_BASE_PIOB->PIO_SODR = LED_A;
// AT91C_BASE_PIOC->PIO_SODR = LED_B;

//delay();

/* Turn LED off */
// AT91C_BASE_PIOB->PIO_CODR = LED_A;
// AT91C_BASE_PIOC->PIO_CODR = LED_B;
// delay();

AT91C_BASE_PIOD->PIO_SODR /* giving +ve pulse to winding c */
AT91C_BASE_PIOD->PIO_CODR
AT91C_BASE_PIOD->PIO_CODR;
AT91C_BASE_PIOD->PIO_CODR;/* giving -ve pulse to winding d */
pulsedelay(); /* time delay*/

AT91C_BASE_PIOD->PIO_SODR; /* giving +ve pulse to winding B */
AT91C_BASE_PIOD->PIO_CODR; /* giving -ve pulse to winding A */
AT91C_BASE_PIOD->PIO_CODR
AT91C_BASE_PIOD->PIO_CODR
pulsedelay(); /* time delay*/

AT91C_BASE_PIOD->PIO_SODR /* giving +ve pulse to winding B */
AT91C_BASE_PIOD->PIO_CODR /* giving -ve pulse to winding B */
AT91C_BASE_PIOD->PIO_CODR;
AT91C_BASE_PIOD->PIO_CODR;
pulsedelay(); /* time delay*/

AT91C_BASE_PIOD->PIO_SODR; /* giving +ve pulse to winding B */
AT91C_BASE_PIOD->PIO_CODR; /* giving -ve pulse to winding A */
AT91C_BASE_PIOD->PIO_CODR
AT91C_BASE_PIOD->PIO_CODR
pulsedelay(); /* time delay*/

}
}

void delay()
{
unsigned int i;
for(i=0;i<0xfffff;i++);
}

void pulsedelay()
{
unsigned int i;
for(i=0;i<0xfffff;i++);
}
ATMEL AT91SAM9263 EK - B is the board that i use.

This is a sample program that i have used to give a sequential output through the pins 3,4,5 & 6 of J25. Could someone help me out on how to configure one or two pins of J25 as inputs. It would be of great help to me if u could modify the above program so that if i give 3V input (using a battery) in pin 7 or pin 8(of J25), then a 3v output is given by the board in pin 3 or pin4 (of J25)