I wrote simple code:
But when i change PORTB configuration to PORTB=11000000; then everything is working ok: on turn on relay is denergised, on button SW1 press relay coil energises. So how to explain such microcontroller behaviour? How RB6 is connected with RB7? Tried to write the same code in MikroC and HiTech, result is the same.
On reset relay must be turned off (RA2 low level). But instead of this after reset relay turns on and there is no reaction when i push button SW1 (RB6 port).#include <Ctype.h>
#include <Math.h>
#include <htc.h>
unsigned int adcTime, clock;
void main()
{
TRISA=11000001;
PORTA=00000000;
TRISB=01000000;
PORTB=01000000;
RBPU=0; //turn on PORTB pullups
ADCON1=01111110; //pin AN0-analog, others-digital
for(;
{
if(RB6==0){RA2=1;}else{RA2=0;}
}
}
But when i change PORTB configuration to PORTB=11000000; then everything is working ok: on turn on relay is denergised, on button SW1 press relay coil energises. So how to explain such microcontroller behaviour? How RB6 is connected with RB7? Tried to write the same code in MikroC and HiTech, result is the same.
Attachments
-
141.9 KB Views: 16