CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Error by input_b

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pfaerber
Guest







Error by input_b
PostPosted: Thu Jan 09, 2003 5:17 am     Reply with quote

Wenn I use this Programm

void main()
{
int idummy;

port_b_pullups(FALSE);
set_tris_b(0xf8);
output_bit(PIN_B0,FALSE);
output_bit(PIN_B1,FALSE);
output_bit(PIN_B2,FALSE);


while (TRUE)
{
idummy = input_b();
} // while
} // main

all is fine. Wenn I change the port_b_pullups line to True
the outputs switch to high.
Is this OK ??? (why)
___________________________
This message was ported from CCS's old forum
Original Post ID: 10556
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Error by input_b
PostPosted: Thu Jan 09, 2003 12:45 pm     Reply with quote

:=all is fine. Wenn I change the port_b_pullups line to True
:=the outputs switch to high.
:=Is this OK ??? (why)
--------------------------------------------------------

Make sure your #fuses statement has NOLVP at the end.
See the example below:

#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
#use Delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

I'm not certain that this will solve your problem,
but I think it's possible.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10570
pfaerber
Guest







Re: Error by input_b
PostPosted: Fri Jan 10, 2003 3:41 am     Reply with quote

:=:=all is fine. Wenn I change the port_b_pullups line to True
:=:=the outputs switch to high.
:=:=Is this OK ??? (why)
:=--------------------------------------------------------
:=
:=Make sure your #fuses statement has NOLVP at the end.
:=See the example below:
:=
:=#include <16F877.h>
:=#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
:=#use Delay(clock=8000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
:=
:=I'm not certain that this will solve your problem,
:=but I think it's possible.

I have NOLVP in the config

#include <16F876.h>
#device *=16
#use delay(clock=4000000,RESTART_WDT)
#fuses XT,NOWDT,PUT,BROWNOUT,NOPROTECT,NOLVP
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7)
___________________________
This message was ported from CCS's old forum
Original Post ID: 10588
Tomi
Guest







Re: Error by input_b
PostPosted: Fri Jan 10, 2003 4:16 am     Reply with quote

Yes, because input_x() sets the tris register to input ALL the pins.
If you want to use input_b() but pin0-2 output use this line:
#use FIXED_IO(port_outputs = pin_b0,pin_b1,pin_b2)

After this, the input_b() function sets TRIS_B to 0xF8 instead of 0xFF.

:=Wenn I use this Programm
:=
:=void main()
:={
:= int idummy;
:=
:= port_b_pullups(FALSE);
:= set_tris_b(0xf8);
:= output_bit(PIN_B0,FALSE);
:= output_bit(PIN_B1,FALSE);
:= output_bit(PIN_B2,FALSE);
:=
:=
:= while (TRUE)
:= {
:= idummy = input_b();
:= } // while
:=} // main
:=
:=all is fine. Wenn I change the port_b_pullups line to True
:=the outputs switch to high.
:=Is this OK ??? (why)
___________________________
This message was ported from CCS's old forum
Original Post ID: 10590
pfaerber
Guest







Re: Error by input_b
PostPosted: Fri Jan 10, 2003 5:00 am     Reply with quote

:=:=all is fine. Wenn I change the port_b_pullups line to True
:=:=the outputs switch to high.
:=:=Is this OK ??? (why)
:=--------------------------------------------------------
:=
:=Make sure your #fuses statement has NOLVP at the end.
:=See the example below:
:=
:=#include <16F877.h>
:=#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
:=#use Delay(clock=8000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
:=
:=I'm not certain that this will solve your problem,
:=but I think it's possible.

I have the NOLVP statement :-(

#include <16F876.h>
#device *=16
#use delay(clock=4000000,RESTART_WDT)
#fuses XT,NOWDT,PUT,BROWNOUT,NOPROTECT,NOLVP
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7)
___________________________
This message was ported from CCS's old forum
Original Post ID: 10591
pfaerber
Guest







Re: Error by input_b
PostPosted: Fri Jan 10, 2003 5:24 am     Reply with quote

:=Yes, because input_x() sets the tris register to input ALL the pins.
:=If you want to use input_b() but pin0-2 output use this line:
:=#use FIXED_IO(port_outputs = pin_b0,pin_b1,pin_b2)
:=
:=After this, the input_b() function sets TRIS_B to 0xF8 instead of 0xFF.

Yes it works.

the old input
.................... idummy = input_b();
0026: MOVLW FF
0027: BSF 03.5
0028: MOVWF 06
0029: BCF 03.5
002A: MOVF 06,W
002B: MOVWF 21


the new input
.................... idummy = input_b();
0029: MOVLW F8
002A: BSF 03.5
002B: MOVWF 06
002C: BCF 03.5
002D: MOVF 06,W
002E: MOVWF 21

Thank you for your reply. Now it works fine.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10592
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group