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.

Sam4sd32c gpio registers

Status
Not open for further replies.

embedded_

Newbie level 2
Newbie level 2
Joined
Aug 31, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
20
Hi,

I'm new to the atmel ARM series MCU's and I am trying to create a simple program so that when I press the user button,
the led on de board lights up.
(I am using the SAM4s Xplained pro development board)

I want to do this without the ASF functions, but with the GPIO registers like
PIO_OSR, PIO_ODSR, PIO_PDSR etc.

Can anyone who has experience with this give me some clarification on how to do this?
 

Attachments

  • GPIO.txt
    460 bytes · Views: 78
Last edited by a moderator:

The LED is working properly now so i can turn it on and off,
but I'm still having trouble with the button (so the if statement is not correct)
anyone knows you to read out the button via the PDSR register?

this is what i have now:

Code:
/*
 * SAM4S_Xplained_Pro_firstProject.c
 *
 * Created: 30-8-2015 20:37:29
 *  Author: embedded_
 */ 

/*
	User switch = PC24
	User led = PC23
*/

#include "sam.h"

/**
 * \brief Application entry point.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
    /* Initialize the SAM system */
    SystemInit();
	
	PIOC->PIO_PER = (PIO_PER_P24 | PIO_PER_P23); //PIO enable
	PIOC->PIO_ODR = PIO_ODR_P24; //Input 
	PIOC->PIO_PUER = PIO_PUER_P24; //pull-up resistor button
	PIOC->PIO_OER = PIO_OER_P23; //Output
	
    while (1) 
    {
        if((PIO_PDSR_P24) == 1)
		{
			PIOC->PIO_SODR = PIO_SODR_P23;
		}
		else
		{
			PIOC->PIO_CODR = PIO_CODR_P23;
		}
	}
}
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top