5v to all the Vdd connections on the PIC.
0v to all the Vss connections on the PIC.
Gnd to both sides of the module.
Two of the HV connections to pins C6 and C7 on the PIC.
MCLR pulled up on the PIC
Then the corresponding LV connection for C7 to the UART TXD pin on the module.
Then the LV connection for C6 to the UART RXD connection on the module.
Ideally add a current limiting resistor and LED to the LED line on the module if it doesn't already have one.

Then before anything else run the 'flash an LED' test on the PIC. What you have posted is _not_ correct for the PIC setup. You have the XT oscillator selected (4Mhz max) yet are saying you are running at 20MHz....
The oscillator will probably be failing and running off the internal RC.

Last edited by Ttelmah on Thu Dec 21, 2017 7:59 am; edited 1 time in total

temtronic

Joined: 01 Jul 2010Posts: 6805Location: Greensville,Ontario

Posted: Thu Dec 21, 2017 5:46 am

this line...
setup_adc(ADC_CLOCK_INTERNAL);

is wrong !
Please check the adc section in the datasheet, table 17-1 for WHY it is wrong and what clocks are valid.

I have to assume some 'wizard' defaults this value ?? It appears on a LOT of posts..

This is why we repeat again and again, that the _first_ thing you must do, is the basic 'flash an LED' test, and get this running at the correct rate. Until the CPU is setup to run at the right rate all clock based functions (which includes RS232) will not work right.

srikrishna

Joined: 06 Sep 2017Posts: 74

Posted: Thu Dec 21, 2017 7:29 am

OK tell me which software you used to communicate between pc and bluetooth??

temtronic

Joined: 01 Jul 2010Posts: 6805Location: Greensville,Ontario

Posted: Thu Dec 21, 2017 7:38 am

Something like this after the fuses.

Code:

#use delay(clock=4M) //4MHz xtal

#define LED PIN_B1 //whatever pin the LED and resistor are on

void main()
{
while (TRUE);
{
output_toggle(LED);
delay_ms(500);
}
}

srikrishna

Joined: 06 Sep 2017Posts: 74

Posted: Thu Dec 21, 2017 8:09 am

temtronic wrote:

Something like this after the fuses.

I have tested the blink led program

Ttelmah

Joined: 11 Mar 2010Posts: 14603

Posted: Thu Dec 21, 2017 8:15 am

What speed is it meant to be giving?.

The whole point is that if you set it as Temtronic shows (500mSec on 500mSec off), the flash should be exactly 1/second. Your video looks like about 4 seconds, which would then mean the CPU is actually running at 1/4 the rate you think it is.

Since your oscillator setup is impossible for the chip, it will probably be falling back to the default RC oscillator.

Serial is not going to work until this is flashing at exactly the speed it is meant to be giving.....

srikrishna

Joined: 06 Sep 2017Posts: 74

Posted: Thu Dec 21, 2017 8:17 am

Ttelmah wrote:

What speed is it meant to be giving?.

The whole point is that if you set it as Temtronic shows (500mSec on 500mSec off),

Previously i have set the 100ms delay. Now i set it to 500ms.

temtronic

Joined: 01 Jul 2010Posts: 6805Location: Greensville,Ontario

Posted: Thu Dec 21, 2017 11:30 am

It appears to be very, very slow...though that could be the internet.
Would have to see the fuses related to clocks. I suspect the main clock is NOT running and the failsafe clock may be running.
A 20MHz xtal would need 2, say 15-22pfd caps.

Jay

Ttelmah

Joined: 11 Mar 2010Posts: 14603

Posted: Thu Dec 21, 2017 12:34 pm

As I have pointed out twice, he is selecting the wrong oscillator.
Hint HS is for a crystal over 4MHz.

srikrishna

Joined: 06 Sep 2017Posts: 74

Posted: Fri Dec 22, 2017 2:56 pm

I have measured the level converter output my level converter output is (4.01-3.99)v. when i applied 5v to its high voltage site and 3.3v to its low voltage site.

The output of Rx pin of Bluetooth is (3.19-3.15)v

As Ttelmah previously told

Quote:

PIC RXD needs the signal to go up to 4v to be seen as a logic '1'. The 3.3v HC05 can't do this.

I think i have to increase the level converter high voltage reference
i mean when i give 5 v it gives 4.1v So
if i give 6v it will give 4.5v or around 5v.Then the pic might regarded as logic '1'

thefloyd

Joined: 02 Sep 2009Posts: 46

Still need to fix your oscillator

Posted: Fri Dec 22, 2017 3:05 pm

As others have already told you repeatedly, your oscillator configuration is way off. You're blinking an LED at either 500/500ms on/off or 100/100ms on/off but your animated picture shows your LED blinking at *way longer* intervals - something like 8 seconds. If you're asking for a 500ms blink and you're blinking at 8s you're way off. Even if you get your voltage levels sorted, your serial communications *will not* work with a bad oscillator configuration.

temtronic

Joined: 01 Jul 2010Posts: 6805Location: Greensville,Ontario

Posted: Fri Dec 22, 2017 5:55 pm

As others have said, you need to go back ...
Get the 1Hz LED running. Delete ALL other code ! NO ADC, NO bluetooth, Nothing but

device header
fuses
main()
toggle led
forever

You NEED to do that BEFORE adding anything else. ONCE you get that running, then proceed.