нашел программу которая считывает серийный номер карточки Em-marine и выдает его в терминал. в протеусе все работает нормально а в реальности ноль..... вот такой у меня считыватель. думал сперва считыватель вышел из строя,взял новый такая же беда http://www.ironlogic.by/il.NSF/pages/matrixII.
Вот программа для codevision
#include <mega32.h>
#include <delay.h>
// 1 Wire Bus functions
#asm
.equ __w1_port=0x12 ;PORTD
.equ __w1_bit=7
#endasm
#include <1wire.h>
// Standard Input/Output functions
#include <stdio.h>
#define DS1990_FAMILY_CODE 1
#define SEARCH_ROM 0xF0
// Declare your global variables here
#define MAX_DEVICES 8
unsigned char rom_code[MAX_DEVICES][9];
// Declare your global variables here
void main(void)
{
unsigned char i,j,devices;
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
ACSR=0x80;
SFIOR=0x00;
w1_init();
while (1)
{
delay_ms(500);
w1_init();
devices=w1_search(SEARCH_ROM,&rom_code[0][0]);
for (i=0;i<devices;i++)
if (rom_code[0]==DS1990_FAMILY_CODE)
{
for (j=1;j<=6;j++)
printf(" %02X",rom_code[j]);
printf("\n\r");
};
};
}
Вот программа для codevision
#include <mega32.h>
#include <delay.h>
// 1 Wire Bus functions
#asm
.equ __w1_port=0x12 ;PORTD
.equ __w1_bit=7
#endasm
#include <1wire.h>
// Standard Input/Output functions
#include <stdio.h>
#define DS1990_FAMILY_CODE 1
#define SEARCH_ROM 0xF0
// Declare your global variables here
#define MAX_DEVICES 8
unsigned char rom_code[MAX_DEVICES][9];
// Declare your global variables here
void main(void)
{
unsigned char i,j,devices;
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
ACSR=0x80;
SFIOR=0x00;
w1_init();
while (1)
{
delay_ms(500);
w1_init();
devices=w1_search(SEARCH_ROM,&rom_code[0][0]);
for (i=0;i<devices;i++)
if (rom_code[0]==DS1990_FAMILY_CODE)
{
for (j=1;j<=6;j++)
printf(" %02X",rom_code[j]);
printf("\n\r");
};
};
}
