EmbeddedRelated.com
Forums
Memfault Beyond the Launch

need help to work with ARM at91sam7x256

Started by nixxterlid September 24, 2008
The Keil IDE has example programs for the AT91SAM7S256. That was the basis for the instrument development I implemented. There are several examples provided.

Jerry

From: A... [mailto:A...] On Behalf Of nixxterlid
Sent: Thursday, October 02, 2008 12:21 PM
To: A...
Subject: [AT91SAM] Re: need help to work with ARM at91sam7x256

i really desperate trying right now. n i'm totally stuck..
i dont know what should i know now..
i've tried to follow each step on the rowley crosswork but i came out of nothing at all..
can anyone give me a real SIMPLE CODING (for example displaying hello message), with appropriate SIMULATOR..i've tried to search everywhere but my worst i couldn't find any..
That really does look extremely simple :-)

Best Regards,
Kris
________________________________________
From: A... [mailto:A...] On Behalf Of
Tony Brenke
Sent: Friday, 3 October 2008 12:55 PM
To: A...
Subject: {Disarmed} Re: [AT91SAM] Re: need help to work with ARM
at91sam7x256

simple PWM led using Rowley

// This program shows how to work whit SPI interface and
// connected to it multimedia card
// Programs read/write buffer to MMC card
#define __inline inline
#include
#include
#include "board.h"
#include "system.h"
#include
#include "avrage.h"
#include "usart.h"
#include "adc.h"
#include
#include

#pragma data_alignment=4

//MAIN POINTER
AT91PS_PIO m_pPio = AT91C_BASE_PIOA;

//local SUB
void set_directionl(char val);
void set_directionr(char val);


//global var
unsigned char outstr[80];
unsigned char counter;
unsigned int adcval;
float V;

#define TWI_BUS_CLOCK 400000 /* in Hz*/

/* value of the PIT value to have 333ns @ 48 MHz
668 -1 since real time out = PIV + 1 */
#define PIT_PIV_MILI_SECOND_VALUE 0x667

/* value of the PIT value to have 333ns @ 48 MHz
3 -1 since real time out = PIV + 1 */
#define PIT_PIV_MICRO_SECOND_VALUE 0x2


int main()
{
int counter=0;
int ret;
int state;

// System init
InitFrec();

//setup IO
InitPeriphery();

// START PWM setup
AT91F_PWM_CfgPMC();// enable clock
AT91F_PWM_CH0_CfgPIO();
AT91F_PWM_CH1_CfgPIO();

AT91F_PIO_CfgOutput(P23);//disable PWM
AT91F_PIO_CfgOutput(P11);//disable PWM
AT91F_PIO_CfgOutput(P24);//disable PWM
AT91F_PIO_CfgOutput(P12);//disable PWM

AT91F_PIO_CfgOutput(P7);//direction lines Left
AT91F_PIO_CfgOutput(P2);//direction lines Right


AT91F_PWM_CfgChannel(AT91C_PWMC_CHID0, (int)(10|1<<8), 100, 50);
AT91F_PWM_CfgChannel(AT91C_PWMC_CHID1, (int)(10|1<<8), 100, 50);

AT91F_PWM_StartChannel(AT91C_PWMC_CHID0);
AT91F_PWM_StartChannel(AT91C_PWMC_CHID1);

// end PWM setup




// setup adc
InitADC();

// setup usart0
// InitUSART0(115200);
// setup usart1
InitUSART1(115200);

// setup RTS Interupt for COM0
init_PIO_interupt();

// config TWI
AT91F_TWI_Open(TWI_BUS_CLOCK);

counter= AT91F_WDTGetPeriod(30);
AT91F_WDTSetMode ( AT91C_WDTC_WDRSTEN | AT91C_WDTC_WDRPROC|counter);
AT91F_WDTC_CfgPMC();




AT91F_PIO_CfgOutput(P12);
AT91F_PIO_ClearOutput(P12);

AT91F_PIO_CfgOutput(P31);
AT91F_PIO_SetOutput(P31);
AT91F_PIO_ClearOutput(P31);
AT91F_PIO_SetOutput(P31);
__enable_interrupt();
printf("Start 1\r");


printf("end\r");
set_directionl(0);
set_directionr(0);

set_directionl(1);
set_directionr(1);

counter =0;
wait_m(150);

while(1){
AT91F_WDTRestart();
counter++;
AT91F_PWM_UpdateChannel(AT91C_PWMC_CHID0,counter);
printf("Counter %u\r",counter);
AT91F_PIO_SetOutput(P31);
AT91F_PWM_UpdateChannel(AT91C_PWMC_CHID1,500);

wait_m(250);
AT91F_PIO_ClearOutput(P31);
AT91F_PWM_UpdateChannel(AT91C_PWMC_CHID1,0);
wait_m(250);

}
}



void set_directionl(char val){
if(val==1){
AT91F_PIO_SetOutput(P7);
}
else{
AT91F_PIO_ClearOutput(P7);
}
};

void set_directionr(char val){
if(val==1){
AT91F_PIO_SetOutput(P2);
}
else{
AT91F_PIO_ClearOutput(P2);
}
};





----- Original Message -----
From: nixxterlid
To: A...
Sent: Thursday, October 02, 2008 10:20 AM
Subject: [AT91SAM] Re: need help to work with ARM at91sam7x256

i really desperate trying right now. n i'm totally stuck..
i dont know what should i know now..
i've tried to follow each step on the rowley crosswork but i came out of
nothing at all..
can anyone give me a real SIMPLE CODING (for example displaying hello
message), with appropriate SIMULATOR..i've tried to search everywhere but my
worst i couldn't find any..

________________________________________

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.173 / Virus Database: 270.7.5/1702 - Release Date: 10/1/2008
9:05 AM


Memfault Beyond the Launch