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

bluetooth hc-06 and hc-05

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



Joined: 10 Dec 2012
Posts: 1

View user's profile Send private message

bluetooth hc-06 and hc-05
PostPosted: Mon Dec 10, 2012 7:58 pm     Reply with quote

hi, I tried operating a Bluetooth module, but I have not been successful, the Bluetooth module are HC-06 and HC-05, attempt Smarth communicate with Android 2.3, but I get absolute rubbish




Code:

//Archivos de cabecera:

#include "18F45k22.h"

#FUSES NOWDT,INTRC,NOMCLR
#use delay(clock=4000000)

#include "flex_lcd.h"

/* configure and enable uart, use first hardware UART on PIC */
#use rs232(uart1, baud=9600)

char dato_recibido[16];          /// aqui va a ir los datos recibidos por rs232

#int_rda
 void rd_isr(void)// datos USART               
 {
   gets(dato_recibido);

   }

void main()
{
lcd_init();
enable_interrupts(global);//Habilito interrupcion global
enable_interrupts(int_rda); //Habilito interrupción USART
   


//printf("AT+BAUD4");
delay_ms(20);

//printf("AT+PN");

while(1){

   lcd_gotoxy(1,1);

   printf("AT+VERSION");   
   printf("\n");
   delay_ms(2000);
   printf(lcd_putc,"%s",dato_recibido);

//   lcd_putc("%s",dato_recibido);

//   dato_recibido="";

   delay_ms(2000);

       }   
}
WingNut



Joined: 04 Nov 2012
Posts: 6
Location: NC

View user's profile Send private message

PostPosted: Mon Dec 10, 2012 8:27 pm     Reply with quote

First, you didn't say what version of compiler you are using.

Test things one at a time:-

1) Get 1Hz LED flasher going, to confirm PIC is OK.
2) Get the RS232 to work. Note : add ERRORS to the #USE RS232
2) Get LCD to work
3) Then add Bluetooth.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Dec 11, 2012 7:37 am     Reply with quote

It often helps to understand what a specific interrupt does in hardware before writing code. An example is the RDA interrupt. The hardware receives characters and interrupts for each and every character. This means the code in the RDA isr must also just accept a single char and exit after having done the bare minimum of other things like place the single char into a RAM buffer increment a pointer etc. The code must always be as lean and mean as is possible especially with RDA since the next character needs to be accepted without much delay. The use of gets (usually accepts a string of n chars ) breaks the rule of understanding the hardware before coding.
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