View previous topic :: View next topic |
Author |
Message |
cencan
Joined: 11 Apr 2014 Posts: 2
|
a question about command output_bit(x,y) |
Posted: Fri Apr 11, 2014 4:19 pm |
|
|
hi everyone. I have a problem. I use very simple command output_bit(x,y) but I can not work it. I am sharing you my commands and screenshot of proteus of my circuit. first command is working correctly but second and third command give me +5V always on PIN_E1 and E2. It is very simple command but I can not understand why it is not change, why give me always +5V?
output_bit(PIN_E0, DZEMIN); //it is working
output_bit(PIN_E1, SZEMIN); //it is not working
output_bit(PIN_E2, KZEMIN); //it is not working
Code: | #include <main.h>
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use fast_io(e)
//KABIN DISI BUTONLARI
#define DZEMIN first_ls165(3)
///////////////////////first ls165////////////////
#define first_lsclock pin_b1
#define first_lsshld pin_b2
#define first_lsso pin_b0
///////////////////////////////////////////////////
#define SZEMIN pin_d5
#define KZEMIN pin_a3
////////////////////first ls165//////////////////////
int1 first_ls165(int i){
int1 firstarray[8];
int firsta;
output_low(first_lsshld);
delay_us(10);
output_high(first_lsshld);
for (firsta=0;firsta<8;firsta++)
{
firstarray[firsta]=input(first_lsso);
delay_us(10);
output_high(first_lsclock);
delay_us(10);
output_low(first_lsclock);
delay_us(10);}
return firstarray[i];
}
//////////////////////////////////////////////
void main()
{
setup_spi(SPI_SS_DISABLED); // SPI birimi devre dışı
setup_timer_1(T1_DISABLED); // Timer1 devre dışı
setup_timer_2(T2_DISABLED,0,1); // Timer2 devre dışı
setup_adc_ports(NO_ANALOGS); // ANALOG girdi yok
setup_adc(ADC_OFF); // ADC birimi devre dışı
setup_CCP1(CCP_OFF); // CCP1 birimi devre dışı
setup_CCP2(CCP_OFF); // CCP2 birimi devre dışı
set_tris_a(0b001111); //
set_tris_b(0b01110001); //
set_tris_c(0b00000000); //
set_tris_d(0b00111100); //
set_tris_e(0b00000000); //
output_a(0x00);
output_b(0x00);
output_c(0x00);
output_d(0x00);
output_e(0x00);
while(true)
{
{
output_bit(PIN_E0, DZEMIN);
output_bit(PIN_E1, SZEMIN);
output_bit(PIN_E2, KZEMIN);
}
}
} |
|
|
|
cencan
Joined: 11 Apr 2014 Posts: 2
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 11, 2014 6:08 pm |
|
|
We don't have to consider Proteus. Let's just look at the CCS
function syntax. Here is a section of your code:
Quote: |
#define SZEMIN pin_d5
#define KZEMIN pin_a3
output_bit(PIN_E1, SZEMIN);
output_bit(PIN_E2, KZEMIN);
|
Your code above is evaluated by the compiler into this:
Quote: |
output_bit(PIN_E1, PIN_D5);
output_bit(PIN_E2, PIN_A3);
|
This is not the correct syntax for the output_bit statement. You should
not give it two pin names. Download the CCS manual and read the
section on output_bit():
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf |
|
|
|