Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

SPI on AVR to generate a square signal

Status
Not open for further replies.

Eugen_E

Full Member level 6
Joined
Nov 29, 2004
Messages
382
Helped
44
Reputation
86
Reaction score
11
Trophy points
1,298
Location
Romania
Activity points
2,839
Hello,

I want to use SPI as master on ATmega8 clocked at 16MHz to generate a fast square signal on MOSI - not for data transmission, but for signal generation. To do this I configure SPI as master at 2Mb/s and write the 8 signal "samples" in SPDR register. In the SPI interrupt (generated at end of transmission of the previous "samples") I write 8 new "samples" in SPDR.

Because the SPI in AVR in transmission is not double buffered, i want to ask if there will be a gap in the MOSI signal between the succesive 8 samples. In the interrupt routine, I write imediatly the new SPDR value - it is computed outside ISR, in the main program.

Also, when i simulated in AVR studio, with SPDR=0xFF, the MOSI output isn't continously '1' when it transmits 0xFF, but 1010101010101010 - i think it is '1' only on the sampling edges of the SCK signal. This is strange.

I've used SPI before for communication with other chips, but without observing the actual SPI signals.
 

Eugen_E

Full Member level 6
Joined
Nov 29, 2004
Messages
382
Helped
44
Reputation
86
Reaction score
11
Trophy points
1,298
Location
Romania
Activity points
2,839
Can I use TWI/I2C instead of SPI for signal generation? The SPI is atractive because it has higher speed.

I could generate the signal simply, without SPI. The reason for SPI in signal generation is that I need to do some other things in the main prog. Without SPI I would write a code only for signal generation, very time constrained, waisting the uC power - I can't do some extern interfacing, just signal generation.

To clarify, I need to design a DDS (direct digital synthesis) for square signals, with frequency variable from 0.1Hz to at least 500kHz, in 0.1Hz steps.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top