Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: I cannot receive data from at91sam7x256,why?
PostPosted: Mon Aug 09, 2010 10:36 am 
Offline

Joined: Mon Aug 09, 2010 10:17 am
Posts: 2
I use keil3 and ulink to compile the code of at91sam7x256.
the code is :
Code:
#include <AT91SAM7X256.H>       
#define US_RXD (1<<5)
#define US_TXD (1<<6)
#define AT91B_MAIN_OSC        18432000               // Main Oscillator MAINCK
#define AT91B_MCK             ((18432000*73/14)/2)   // Output PLL Clock
#define BR    9600                        /* Baud Rate */
#define BRD  (AT91B_MCK/16/BR)              /* Baud Rate Divisor */
AT91S_USART * pUSART = AT91C_BASE_US0;
unsigned char buff[256];
unsigned char index;
sendchar (int ch) 

    while (!(pUSART->US_CSR & AT91C_US_TXRDY));   /* Wait for Empty Tx Buffer */
    return (pUSART->US_THR = ch);                                                         
}
int main(void)
{
   unsigned int i,delay;
   *AT91C_PMC_SCER=AT91C_CKGR_MOSCEN;
   *AT91C_PMC_PCER=(1<<AT91C_ID_US0);   
   *AT91C_PIOA_PDR=US_RXD|US_TXD;   
   *AT91C_PIOA_ASR=US_RXD|US_TXD;   
   //*AT91C_US1_CR=0x10c;           
   *AT91C_US0_CR=AT91C_US_RSTRX|AT91C_US_RSTTX|AT91C_US_RXDIS|AT91C_US_TXDIS;
   *AT91C_US0_MR=0x8c0;           
   *AT91C_US0_IDR=0xf3fff;         
   *AT91C_US0_BRGR=BRD;                         
   //*AT91C_US1_CR=0x10c;           
   *AT91C_US0_CR=0x50;             
   while(1)      
   {
      for(i=1;i<10;i++)
      {
         sendchar(i);
         for(delay=0;delay<1000;delay++);
      }
      
   }
}

but i cannot receive any data from the board,why?please help me!


Top
 Profile  
 
 Post subject: Re: I cannot receive data from at91sam7x256,why?
PostPosted: Mon Aug 09, 2010 10:30 pm 
Offline

Joined: Thu Feb 25, 2010 5:02 pm
Posts: 88
Hello,

Quote:
#define US_RXD (1<<5)
#define US_TXD (1<<6)


I believe if you are using USART0 these pins should be:
Code:
#define US_RXD (1<<0)      // USART0 - RXD0 (PA0)
#define US_TXD (1<<1)      // USART0 - TXD0 (PA1)


Regards

_________________
Duane P. Fridley, IEEE CSDP
Viable Bytes, Inc.


Top
 Profile  
 
 Post subject: Re: I cannot receive data from at91sam7x256,why?
PostPosted: Tue Aug 10, 2010 3:04 am 
Offline

Joined: Mon Aug 09, 2010 10:17 am
Posts: 2
:oops:
thank you for your attention!
i have changed the define of "US_RXD" and "US_TXD",but the question still exist.
the value of the register US_THR is zero all the time.
cannot receive any data from the board.


Any advise would be welcome ! Thanks !


Top
 Profile  
 
 Post subject: Re: I cannot receive data from at91sam7x256,why?
PostPosted: Mon Aug 16, 2010 3:12 pm 
Offline

Joined: Thu Feb 25, 2010 5:02 pm
Posts: 88
Hello -

Have you been able to get this to work?

I would recommend firing up your debugger and stepping through the code.

My guess is that your code never exits the while loop in the sendchar() routine.

If so... you might want to try checking the TXEMPTY bit instead of the TXRDY bit.

Regards,

_________________
Duane P. Fridley, IEEE CSDP
Viable Bytes, Inc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: