| ??? 01/23/03 14:31 Read: times |
#36991 - RE: SPI |
Hi friends this is part of the code that handles communication;This Program Written for AT89c51 mProcessor
;to Record & Playback Audio As Interfaced ;with isd4004 sound chip on SPI protocol $mod51 $noprint SPCR DATA 0D5H ;SPI CONTROL REGISTER SPSR DATA 0AAH ;SPI STATUS REGISTER SPIF EQU 10000000b ;INTERRUPT FLAG SPDR DATA 86H ;SPI DATA REGISTER CS EQU P1.4 ;SLAVE SELECT MOSI EQU P1.5 ;SPI MISO EQU P1.6 ;SPI SCK EQU P1.7 ;SPI rec_button equ p0.0 rec_led equ p2.7 play_button equ p0.1 play_led equ p2.6 stop_button equ p0.2 stop_led equ p2.5 RDSR equ 05h ;read status register WRSR equ 01h ;write status register READ equ 03h ;read data from slave WRITE equ 02h ;write data to slave WREN equ 06h ;write enable WRIDI equ 04h ;write disable A8 bit acc.3 ;msb of address NRDY bit acc.0 ;high=write cycle in progress org 0000h setup: setb cs setb mosi setb miso setb sck mov spcr,#55h setb Play_button setb rec_button setb stop_button setb rec_led setb play_led setb stop_led clr a jmp operations operations: lcall check1 lcall check2 lcall check3 lcall check4 sjmp operations check1: jnb play_button,playm ret check2: jnb rec_button,recordm ret check3: jnb stop_button,stopm ret RECORDm: clr rec_led setb play_led setb stop_led clr cs mov a,#powerup rrc a call write_byte call delay mov a,#setrec rrc a call write_byte call delay mov a,#rec rrc a call write_byte call delay setb cs setb rec_button clr a ret Playm: setb rec_led clr play_led setb stop_led clr cs mov a,#powerup rrc a call write_byte call delay mov a,#setplay rrc a call write_byte call delay mov a,#play rrc a call write_byte call delay setb cs setb play_button clr a ret stopm: setb rec_led setb play_led clr stop_led clr cs mov a,#stop rrc a call write_byte call delay setb cs setb stop_button clr a ret write_byte: clr cs push acc mov a,dph rrc a mov a,#write mov a8,c call masterio mov a,dpl call masterio pop acc call masterio setb cs ret masterio: mov spdr,a ;write output data ret check4: cpl P2.2 ret ;4004 control code powerup: db '00100111' setplay: db '11100111' play: db '11110111' setrec: db '10100111' rec: db '10110111' setmic: db '11101000' mc: db '11111111' stop: db '01110111' stoppwrdn: db '01011111' rint: db '01110111' end |
| Topic | Author | Date |
| SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
| RE: SPI | 01/01/70 00:00 | |
RE: SPI | 01/01/70 00:00 |



