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.

Error using SPI in ATmega64!!!!!!!1

Status
Not open for further replies.

Circuit_seller

Full Member level 5
Full Member level 5
Joined
Sep 23, 2002
Messages
300
Helped
17
Reputation
34
Reaction score
7
Trophy points
1,298
Visit site
Activity points
2,350
Hi there,

I am trying to use SPI in programming a DDS serialy.
Unfortunately i can not use SPI correctly.
I done a simple test and write this program. but the micro continusly send data and Serial Clock.
Can anyone say what is the problem.

#include <iom64v.h>
#include <macros.h>
#include "define.h"

void SPI_Send(char cData)
{
/* Start transmission */
SPDR = cData;
/* Wait for transmission complete */
while(!(SPSR & (1<<SPIF)));
}

void main(void)
{

int i=0;

PORTF = 0x00;
DDRF = 0xdf;
PORTA = 0x00;
DDRA = 0xff;
PORTB = 0x00;
DDRB = 0xff;
SPCR = 0x55; //setup SPI
SPSR = 0x00; //setup SPI
SPI_Send(0x46);
while(1)
;
}
 

Hi

Yes, i have defined it volatile.

#define SPSR (*(volatile unsigned char *)0x2E)

What is the problem?

Regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top