Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to Manipulate AT91SAM7S256 Pins

Status
Not open for further replies.

xerox786

Newbie level 2
Joined
Mar 12, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
I would like to get a digital sequence at output pins of this MC.

Thanks
 

Hi,

Look at the data sheet for register description.
You need to configure pin as output and write data to output register in order to change state
 

Hi,

Look at the data sheet for register description.
You need to configure pin as output and write data to output register in order to change state

Thanks for the reply.
I know how to configure pin but how should i wrote data or those registers could you help me .... can you give me little support on team viewer ?
 

The following "blinky" example code outputs a pattern on four pins attached to LEDs:

blinky.c
Code:
/******************************************************************************/
/* BLINKY.C: LED Flasher                                                      */
/******************************************************************************/
/* This file is part of the uVision/ARM development tools.                    */
/* Copyright (c) 2005-2006 Keil Software. All rights reserved.                */
/* This software may only be used under the terms of a valid, current,        */
/* end user licence from KEIL for a compatible version of KEIL software       */
/* development tools. Nothing else gives you the right to use this software.  */
/******************************************************************************/
                  
#include <AT91SAM7S64.H>                       /* AT91SAMT7S64 definitions  */
#include "..\Board.h"

#define SPEED (MCKKHz/10)

const int led_mask[] = { LED1, LED2, LED3, LED4 };

unsigned int LEDSpeed = 50*SPEED;


/* 
 * Change Speed depending on SW1 and SW2
 */

void change_speed (void) {
  if ((AT91C_BASE_PIOA->PIO_PDSR & SW1_MASK) == 0) {
    if (LEDSpeed > SPEED) LEDSpeed -= SPEED;
  }
  if ((AT91C_BASE_PIOA->PIO_PDSR & SW2_MASK) == 0) {
    if (LEDSpeed < MCK)   LEDSpeed += SPEED;
  }
}


/*
 * Wait Function (SW Waiting Loop)
 *   Waiting Time defined by global variable LEDSpeed
 */
 
void wait (void) {
  unsigned int n;

  change_speed();
  for (n = 0; n < LEDSpeed; n++);
}
  

/*
 * Main Program
 */

int main (void) {
  int i;

  // Enable the Clock of the PIO
  AT91C_BASE_PMC->PMC_PCER  = 1 << AT91C_ID_PIOA;

  // Configure the PIO Lines corresponding to LED1..LED4 as Outputs
  AT91C_BASE_PIOA->PIO_PER  = LED_MASK;
  AT91C_BASE_PIOA->PIO_OER  = LED_MASK;

  // Clear the LED's. On the Board we must apply a "1" to turn off LEDs
  AT91C_BASE_PIOA->PIO_SODR = LED_MASK;

  // Loop forever
  for (;;) {
    for (i = 0; i < NB_LED; i++) {
      AT91C_BASE_PIOA->PIO_CODR = led_mask[i];
      wait();
      AT91C_BASE_PIOA->PIO_SODR = led_mask[i];
      wait();
    }
    for (i = (NB_LED - 1); i >= 0; i--) {
      AT91C_BASE_PIOA->PIO_CODR = led_mask[i];
      wait();
      AT91C_BASE_PIOA->PIO_SODR = led_mask[i];
      wait();
    }
  }
}

BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top