Re: Мелкие вопросы по МК и ПЛИС.
Добавлено: Чт дек 13, 2012 15:58:37
Коты, есть зацепка, watchdog! Сейчас выключил его фьюзом, нужно его дополнительно выключать программно?
Здесь можно немножко помяукать :)
https://radiokot.ru/forum/
Код: Выделить всё
#define F_CPU 20000000
#include <avr/io.h>
#include <util/delay.h>
#define BAUD 129
//BAUD ((F_CPU/(USART_SPEED*16)) - 1) : ( 20 000 000 / (9600*16) ) - 1 = 129
inline void USART_Init( unsigned int baud ){
/* Устанавливаем скорость */
UBRRH = (unsigned char)(baud>>8);
UBRRL = (unsigned char)baud;
/* Включаем прием и передачу */
UCSRB = (1<<RXEN)|(1<<TXEN);
/* Устанавливаем формат: 8n1 */
UCSRC = ( 0 << UCSZ2 ) | ( 1 << UCSZ1 ) | ( 1 << UCSZ0 ) | ( 0 << UPM1 ) | ( 0 << UPM0 ) | (0 << USBS);
}
int main(void){
USART_Init(BAUD);
_delay_ms(1000);
UDR = 0x43;
while(1){}
return 0;
}Код: Выделить всё
43 43 43 43 43 43 43 43 83 43 A1 A3 CB 43 43 43 FE 43 43 43 85 43 43 43 94 43 43 43 E3 A3 83 43 43 C3 43 BE 43 43 43 C3 43 43 43 43 FF 43 43 43 A3 A3 43 A3 43 43 C3 43 A3 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43Прерывание[внешнее_от_лапки_INT0] не параметрируемое Название (без параметров). А искать описание объявлений всех прерываний в хелпе к кодевижену.interrupt [EXT_INT0] void ext_int0_isr(void)
Странные люди что может сказать человекунезнаю даже почему это нагляднее, как помне это лишняя информация
Всегда пожалуйставы мне помогаете на протяжении всего моего пути програмирования контролеров, большое вам за это спасибо
3.2 ВВольтметром померяйте напряжение питания. Напишите сюда. Схема включения должна быть примерно такой (см. картинку).
Код: Выделить всё
PUB start_explicit( DO, CLK, DI, CS ) : card_type | tmp, i
{{
Do all of the card initialization in SPIN, then hand off the pin
information to the assembly cog for hot SPI block R/W action!
}}
' (start with cog variables, _BEFORE_ loading the cog)
pinDO := DO
maskDO := |< DO
pinCLK := CLK
pinDI := DI
maskDI := |< DI
maskCS := |< CS
adrShift := 9 ' block = 512 * index, and 512 = 1<<9
' pass the output pin mask via the command register
maskAll := maskCS | (|<pinCLK) | maskDI
dira |= maskAll
' get the card in a ready state: set DI and CS high, send => 74 clocks
outa |= maskAll
repeat 4096
outa[CLK]~~
outa[CLK]~
' time-hack
SPI_block_index := cnt
' reset the card
tmp~
repeat i from 0 to 9
if tmp <> 1
tmp := send_cmd_slow( CMD0, 0, $95 )
if (tmp & 4)
' the card said CMD0 ("go idle") was invalid, so we're possibly stuck in read or write mode
if i & 1
' exit multiblock read mode
repeat 4
read_32_slow ' these extra clocks are required for some MMC cards
send_slow( $FD, 8 ) ' stop token
read_32_slow
repeat while read_slow <> $FF
else
' exit multiblock read mode
send_cmd_slow( CMD12, 0, $61 )
if tmp <> 1
' the reset command failed!
crash( ERR_CARD_NOT_RESET )Бред!!!Arlleex писал(а):Возможно вы неверно соединили линии MISO и MOSI.
MISO----->MISO
MOSI----->MOSI - так должно быть.
Чего не замечали??? Повышения тока потребления при работе SD ???Arlleex писал(а):Странное поведение... Никогда не замечал такого.
Был бы он - было бы понятнее, что там с питанием.Пробуйте все-таки с питанием разобраться, без осциллографа сложнова-то будет. Тыкните им на вывод питания что там за картина?
Если карточка работает в родном режиме то да, CMD/DI и DAT0/DO, но она специально и переводится в SPI режим, тогда выводы и можно назвать MOSI и MISO. И разве MOSI не расшифровывается Master Out Slave In?MISO----->DO
MOSI----->DI - вот так должно быть.
Код: Выделить всё
sendSD
mov circle, #8 '8 bits
'sending cirlce
send_loop mov calc, sndByte
and calc, #$80
cmp calc, #0 wz
or outa, mosi
if_z andn outa, mosi
or outa, clock
shl sndByte, #1
andn outa, clock
cmpsub circle, #1 wz, wr
if_nz jmp #send_loop
shr sndByte, #8
sendSD_ret retКод: Выделить всё
or dira, pins_out 'set pins on out
or outa, pins_st 'set 1 on start out pins
mov sym, #100 '100 cyclres by 8 bit
''initializing SD in SPI
clk_loop mov sndByte, #$FF
call #sendSD
cmpsub sym, #1 wr, wz
if_nz jmp #clk_loop
andn outa, cs1 'set NS to 0
andn outa, cs2
mov sndByte, #$40
call #sendSD
mov sndByte, #$00
call #sendSD
call #sendSD
call #sendSD
call #sendSD
mov sndByte, #$95
call #sendSD