Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC18F4550 Bluetooth Simple Code

Status
Not open for further replies.

clau

Newbie level 5
Newbie level 5
Joined
Nov 13, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
82
Hi everyone!

I want to make a simple test with my PIC18F4550, bluetooth module HC-06 and the computer.
I mean, I want to sent a simple caracter from the PIC to the PC using the bluetooth module.

But I'm having struggles on do this. My code and schematic is next...can somebody help me finding my mistake?

(I'm using RCom Serial or CoolTerminal)

CRYSTAL.jpg

Code:
#include <18f4550.h>
#include <stdio.h> 

#fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP, NOCPD, NOWRT

#use delay (clock=4000000)

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N)


void main ()
{

  while (1)
	{
	printf("A");
	
	}
}


Thanks!
 

Use hyper terminal clones like tera term and connect it to virtual COM port in bluetooth driver in your PC.
I never saw or used #fuses and #use preprocessor in C (may be implemented in xc8), so not sure what it does? I suggest initializing all peripherals (oscillator, UART) in separate Initialize() function. Also, Im not sure how are you communicating to UART, usually an interrupt routine is written and is printf function does implement UART internally and sends and receives character from UART?
If everything is set and working, but still no success, check the UART port of both PIC and bluetooth module by using USB to UART converter and testing it.

Hope that helps.
 

Use hyper terminal clones like tera term and connect it to virtual COM port in bluetooth driver in your PC.
I never saw or used #fuses and #use preprocessor in C (may be implemented in xc8), so not sure what it does? I suggest initializing all peripherals (oscillator, UART) in separate Initialize() function. Also, Im not sure how are you communicating to UART, usually an interrupt routine is written and is printf function does implement UART internally and sends and receives character from UART?
If everything is set and working, but still no success, check the UART port of both PIC and bluetooth module by using USB to UART converter and testing it.

Hope that helps.


Hey, thanks for your help. The #fuses are necessary to disable some watchdog timer and others things. But it is really necessary to initialize the UART and oscillator?

It was supposed to appear an "A" in the terminal but what appear is a F8 in HEX (ASCII:seems like a "o" with a slash inside). I've try instead a printf, a puts or a fputs, but F8 still appears plus this symbol "€".

I can see something in the terminal but not what is supposed to see.

Thanks!
 

Before using the bluetooth module, try to connect the microcontroller to PC using uart.

Make sure that your code is working well.

It seems that you are using CCS C Compiler.

You are sending the character 'A' in the while loop.

A small delay is required after the printf statement. Else, it will hangs.

Hope it may help you.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top