spi unit in an Atmega48

Feb 07, 2008 4 Replies

comp.arch.embedded spi unit in an Atmega48



Does anyone here have some assembley code that works with Atmel's Atmega48 spi unit? The assembley code shown in their datasheet (which required some repair) didn't work. This was done using the register definitions shown in the register listing. To double check that listing a "part specific header file" for the atmega48 would be handy. Anyone know of such a file for either a c compiler or an assembler, preferably in ascii format? Also the latest code attempted is shown below. If anyone see's an error, please mention it. Hul


testing: ; spi output ldi areg, 0x2c ; areg is r16 out SPIDIR, areg ; spidir is 4 ldi areg, 4 out SPIOUT, areg ; spiout is 5



ldi areg, 0x70 sts SPCR, areg ; spcr is 0x2c



ldi bbreg, 0x55 ; bbreg is r17 send: out SPDR, bbreg ; spdr is 0x2e check: in areg, SPSR ; spsr is 0x2d andi areg, 0x80 brne check rjmp send



Hi, I see two problems. 1) should be out SPCR instead of sts SPCR.

2) should be breq check, not brne check.

Mike

Thanks Mike. I'll check the changes and see what happens.

Hul

Mike Silva wrote:

Mike - your suggestions worked perfectly. Many thanks,

Hul

Mike Silva wrote:

Good - happy to help out when I can.

Mike

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required