spi unit in an Atmega48

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

Reply to
Hul Tytus
Loading thread data ...

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

2) should be breq check, not brne check.

Mike

Reply to
Mike Silva

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

Hul

Mike Silva wrote:

Reply to
dbr

Mike - your suggestions worked perfectly. Many thanks,

Hul

Mike Silva wrote:

Reply to
dbr

Good - happy to help out when I can.

Mike

Reply to
Mike Silva

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.