[an error occurred while processing this directive]
|
Программирую порт С: записываю в биты 0..3 еденичку, считываю состояние бита 4. Если бит 4 имеет положительный потенциал, то всё работает, если нулевой, то биты 0..3 тоже на земле....где грабли?
проверил на нескольких имс.
текст прилагается...
// Target : 4433
// Crystal: 8.0000Mhz#include
#include/* enables an unsigned char to be used as a series of booleans */
#define BIT(x) (1 << (x))
#define SETBIT(x, y) (x |= y)
#define CLEARBIT(x, y) (x &= ~y)
#define CHECKBIT(x, y) (x & y)// ***** Define I/O pins *****
#define BIT7 0x80
#define BIT6 0x40
#define BIT5 0x20
#define BIT4 0x10
#define BIT3 0x08
#define BIT2 0x04
#define BIT1 0x02
#define BIT0 0x01
void port_init(void)
{
PORTB = 0x3F;
DDRB = 0x0F;
PORTC = 0x3F;
DDRC = 0x0F;
PORTD = 0xFF;
DDRD = 0x00;
}void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();MCUCR = 0x00;
GIMSK = 0x00;
TIMSK = 0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialised
}char temp;
//
void main(void)
{
init_devices();
while(1)
{
SETBIT( PORTC, BIT0 );
NOP();
CLEARBIT( PORTC, BIT0 );
NOP();
SETBIT( PORTC, BIT1 );
NOP();
CLEARBIT( PORTC, BIT1 );
NOP();
SETBIT( PORTC, BIT2 );
NOP();
CLEARBIT( PORTC, BIT2 );
NOP();
SETBIT( PORTC, BIT3 );
NOP();
CLEARBIT( PORTC, BIT3 );
NOP();
temp = PINC;
PORTB = temp;
}
}
E-mail: info@telesys.ru