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 support@ccsinfo.com

garbage input with rs232 bluetooth but perfect output

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







garbage input with rs232 bluetooth but perfect output
PostPosted: Thu Mar 27, 2008 9:19 am     Reply with quote

Compiler version: 3.245
Pic version: 18F8722

Here a short description of a problem that has really been frustrating me, and its doubly frustrating since I fixed it in the past, but don't remember how now. Also ive searched the forum thoroughly for insight into this problem and havent found an answer, but in case i am rehashing a common topic, i do apologize.

I am able to communicate with the pic using a bluetooth connection, but input is getting garbled, while communication originating from the pic comes through clearly. I tested this by just echoing input back out, as well as following that by putc'ing another character. So when i send the pic something i get garbage output, sometimes random, most times "<0>" , and that is followed by the putc character.

I know hardware is not an issue here, since the same pic has been loaded with working firmware and tested.

Im going to post my code, and i really appreciate if someone could help me shed some light on this. My own intuition tells me it has something to do with fuses, because i know little to nothing about what they do. Thanks!!


Code:

//model of pic
#include <18F8722.H>
//#DEVICE ADC=10

#fuses NOLVP         // Low Voltage ICSP Disabled
#fuses H4
#fuses NOWRT
#fuses NOPUT         // Power Up Timer
//#fuses NOBROWNOUT  // Brown Out Reset enabled
#fuses NOWDT         // no watch dog timer
//#fuses NOPROTECT   // No Code Protect
//#fuses NODEBUG     // No Background Debugger
//#fuses MCLR

//clock speed set here
#use delay(clock=24000000)
//setup of rs232
#use rs232(STREAM=serial,BAUD=115200,XMIT=PIN_C6,RCV=PIN_C7,PARITY=N,BITS=8)


void readPacket();
void init();

void main()
{
   init();
}

//read data available interrupt
#int_rda
void readPacket()
{
   char inchar;
   // While there are incoming bytes waiting to be read...
    while (kbhit())
    {
        // Get an incoming character
        inchar = getc();
        putc(inchar);
        putc('a');
    }
}

void init()
{
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   SET_TRIS_A( 0xff );
   SET_TRIS_B( 0xff );
   SET_TRIS_C( 0xbf );
   SET_TRIS_D( 0xff );
   SET_TRIS_E( 0xff );
   printf("Initilizing\n\r");
}
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Mar 27, 2008 9:45 am     Reply with quote

Most likely something to do with the pic going to sleep after init() in main.

Try putting

while(true) {
}

after init().
This will prevent the pic going to sleep.

No gaurantees with this though!
Guest








PostPosted: Thu Mar 27, 2008 9:49 am     Reply with quote

thanks wayne, actually i did have a while loop in there just looping forever with nothing in it, i didnt think it was necessary, but with it in the same problem still applies.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Mar 27, 2008 10:05 am     Reply with quote

because you are not using fast_io those set_tris statements mean nothing.
They should be done before the enable ints anyway.

Just remove them unless you plan on using fast_io!
ist worker
Guest







PostPosted: Thu Mar 27, 2008 10:10 am     Reply with quote

thanks again, i forgot to put my name in my last post btw.

I put those set_tris statements in to see if it would remedy my problem, but with those statements removed, i still have the same problem.
ist worker
Guest







PostPosted: Thu Mar 27, 2008 11:58 am     Reply with quote

Wow ok, the problem has been solved, thank goodness.

I was powering the PIC circuit board through the ICD-U40 thingy plugged into the usb port rather than through the battery pack. The EE i work with pointed out that it may not be enough power to run bluetooth, and he was right! Using the correct power source solved the problem.
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