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

Problem with #use fast_io(C) & #use rs232

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







Problem with #use fast_io(C) & #use rs232
PostPosted: Mon Aug 08, 2005 6:26 am     Reply with quote

Hello!
Please i need help.....

When in my main application I use:
#use rs232(baud=9600,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8)

and I use also : #use fast_io(C)
in my .c files, my function SHIFT_OUT do not run.

If I do not use fast_io or rs232, My function run ok....why ????


main.c example:

#include <18F452.h>
#fuses NOWDT,HS, PUT, NOPROTECT, NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#include <AD.c>

void main()
{
SHIFT_OUT(DDS_AD9951_CFR1);
SHIFT_OUT(0x00); // OSK Disable, Auto OSK keying OFF
SHIFT_OUT(0x00);
SHIFT_OUT(0x00); // SDIO input only
SHIFT_OUT(0x00); // Power down
delay_us(1);
output_high(IO_UPDATE);
//delay_us(5);
output_low(IO_UPDATE);
}




AD.c example:
#define IO_UPDATE PIN_C0 // pin 15
#define SCLK PIN_C3 // pin 18
#define SDIO PIN_C5 // pin 24
#define DDS_AD9951_CFR1 0x00

#use fast_io(C)
SET_TRIS_C(0B10010000); //set port 1 = INPUT 0 = OUTPUT

//-------------------------
void shift_out(INT8 BYTEn)
//-------------------------
{
// SHIFT MSB FIRST !!!!!
char tmp;

for (tmp = 0; tmp < 8; tmp++)
{

if ((byten & 0b10000000) == 0b10000000)
output_high(SDIO);
else
output_low(SDIO);

BYTEn = BYTEn << 1;

output_high(SCLK);
delay_us(5);
output_low(SCLK);
}
ttelmah
Guest







PostPosted: Mon Aug 08, 2005 6:33 am     Reply with quote

The tris function, needs to be in the code. the use fast_io statement, is a declaration (like the use RS232 statement), and doesn't need to be 'called'. However the tris function, is just that, a _function_, and needs to be called somewhere inside the code, before it'll work. As it stands, the tris funtion is never being called, so the port will default to it's 'power on' state, which is with all pins as inputs. Hence the output shift routine, will never work.
Move your 'set_tris_c' function, to the main, so it is called before you try to do the I/O.

Best Wishes
Guest








PostPosted: Mon Aug 08, 2005 7:29 am     Reply with quote

Many Tnks to ttelmah for answer.

Now I have see in the examples that usually
#set_tris(x)
is in the main() or in init_device() function.

Bye, Gio
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