Korzystam ze standardowej biblioteki CHIPCONA.
Mam następujący problem próbuje odczytać poleceniem ReadFromCC1000Register(...);
jakikolwiek rejestr o tak:
Kod: Zaznacz cały
Kod:
#include <avr/io.h>
#include "lcd.h"
#include "cc1000.c"
int xx;
int main(void)
{
LCD_init();
xx=ReadFromCC1000Register(0x10);
LCD_xy(0,0);
LCD_putint( xx, 2);
for(;;)
{}
} i wyrzuca mi cały czas 11111111.
Pisze w C korzystam z bibliotek chipcona procesor to AT8L.
Wyprowadzenia tak skonfigurowane:
Kod: Zaznacz cały
Kod:
//@ AT8
//portC
#define PALE 3
#define PCLK 4
#define PDATA 5
//portB
#define DIO 4
#define DCLK 5 funkcja tak wygląda po zmianie oryginalnie ustawionego portuD na portC:
Kod: Zaznacz cały
Kod:
/* This routine reads from a single CC1000 register */
/****************************************************************************/
char ReadFromCC1000Register(char addr)
{
char BitCounter;
char Data;
char Debug;
PORTC|=(1<<PALE); //PALE=1
Data=addr<<1;
PORTC&=~(1<<PALE);
/* Send address bits */
for (BitCounter=0;BitCounter<7;BitCounter++)
{
PORTC|=(1<<PCLK); // PCLK=1
if ((Data&0x80)==0) {
PORTC&=~(1<<PDATA); // PDATA=0
}
else {
PORTC|=(1<<PDATA); // PDATA=1
}
Data=Data<<1;
PORTC&=~(1<<PCLK); //PCLK=0;
}
/* Send read/write bit */
/* Ignore bit in data, always use 0 */
PORTC|=(1<<PCLK); //PCLK=1
PORTC&=~(1<<PDATA); //PDATA=0
PORTC&=~(1<<PCLK); //PCLK=0
PORTC|=(1<<PCLK); //PCLK=1
PORTC|=(1<<PALE); //PALE=1
/* Receive data bits */
PORTC|=(1<<PDATA); //PDATA=1
DDRC&=~(1<<PDATA); /* Set up PDATA as an input */
for (BitCounter=0;BitCounter<8;BitCounter++)
{
PORTC&=~(1<<PCLK); //PCLK=0
Data=Data<<1;
Debug=(1<<PDATA);
if ((PINC&Debug)==0) {
Data&=0xFE;
} else {
Data|=0x01;
}
PORTC|=(1<<PCLK); //PCLK=1
}
DDRC|=(1<<PDATA); /* Set up PDATA as an output again */
return Data;
} Proszę o pomoc, bo już nie wiem czy to układ jest uszkodzony czy ja coś robie nie tak ?
[ Dodano: 2006-06-02, 19:14 ]
Już sobie poradziłem. Pozdrawiam.