нда-а-а, тоска, смотреть тута...
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено mse 01 июля 2003 г. 17:16
В ответ на: Супер! отправлено Ирина 01 июля 2003 г. 15:48


write_buffer1_current_page: ;пишу в буфер
push temporary1
rcall set_actual_CS_zero

write_buffer1_current_page_:
sbis pind,FLASH_operation_ready ;читаю ногу "бизи"
rjmp write_buffer1_current_page_

ldi temporary1,buffer_1_write_command
rcall out_byte_to_SPI

ldi temporary1,0
rcall out_byte_to_SPI

lds temporary1,flash_execution_addr_h
andi temporary1,0b00000011
rcall out_byte_to_SPI

lds temporary1,flash_execution_addr_l
rcall out_byte_to_SPI

pop temporary1 ;тут данные для записи
rcall out_byte_to_SPI

rjmp exit_flash_cs_to_one :вываливаюсь, и ЦС=1

move_buffer1_to_current_page: ;шлём буффер в страницу
rcall set_actual_CS_zero

move_buffer1_to_current_page_:
sbis pind,FLASH_operation_ready ; ждём готовности - читаем бизи
rjmp move_buffer1_to_current_page_

ldi temporary1,buffer_1_stor_eras_command
rcall out_byte_to_SPI

lds temporary1,flash_execution_page_h ; там лежит №страницы
lds temporary2,flash_execution_page_l

move_to_current_page:
rol temporary2
rol temporary1
rol temporary2
rol temporary1
andi temporary2,0b11111100
rcall out_byte_to_SPI
mov temporary1,temporary2
rcall out_byte_to_SPI
ldi temporary1,0
rcall out_byte_to_SPI
rjmp exit_flash_cs_to_one ;сваливаем отсюда

move_current_page_to_buffer1: ; читаем текущую стр. в буфер
rcall set_actual_CS_zero

move_current_page_to_buffer1_:
sbis pind,FLASH_operation_ready
rjmp move_current_page_to_buffer1_

ldi temporary1,mem_to_buffer_1_load_command
rcall out_byte_to_SPI

lds temporary1,flash_execution_page_h ;тут №стр.
lds temporary2,flash_execution_page_l

andi temporary1,0b00011111
rol temporary2
rol temporary1
rol temporary2
rol temporary1
andi temporary2,0b11111100

rcall out_byte_to_SPI
mov temporary1,temporary2
rcall out_byte_to_SPI
ldi temporary1,0
rcall out_byte_to_SPI

exit_flash_cs_to_one:
in temporary2,portb ;так мы сваливаем отсюда,
ori temporary2,0b00011100
out portb,temporary2

ret ;данные в буфере будут через некоторое время, см. внизу

send_channel_to_host:

ldi temporary2,128
sub checksumm_reg,checksumm_reg

rcall set_actual_CS_zero
send_channel_to_host_:
sbis pind,FLASH_operation_ready
rjmp send_channel_to_host_

ldi temporary1,buffer_1_read_command ;данные в буфере!!
rcall out_byte_to_SPI

ldi temporary1,0
rcall out_byte_to_SPI

lds temporary1,externl_addr_in_buff1_h
andi temporary1,0b00000011
rcall out_byte_to_SPI

ldi temporary1,0
rcall out_byte_to_SPI

ldi temporary1,0
rcall out_byte_to_SPI

send_next_data_to_host:
ldi temporary1,0
rcall out_byte_to_SPI

in temporary1,spdr
mov source_dat_L,temporary1 ; тут начинается моя песня, к сабжу нет отн.

ldi temporary1,0
rcall out_byte_to_SPI

in temporary1,spdr
mov source_dat_H,temporary1

push temporary2
rcall expand_hex_to_dec

rcall send_expanded_data_to_host
pop temporary2

dec temporary2
brne send_next_data_to_host

mov temporary1,checksumm_reg
neg temporary1
rcall send_byte_as_chars

rjmp exit_flash_cs_to_one


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru