Severals problems with BT and PIC

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
That should be most normal to config as output / input.

But all samples i found online, both is input.
Have even tried Microchips online version, of just create a program, that just send data.
That one also config both as input,

Been tried to change it , even from my first version of it.
, but still no luck.
 

spinnaker

Joined Oct 29, 2009
7,830
That should be most normal to config as output / input.

But all samples i found online, both is input.
Have even tried Microchips online version, of just create a program, that just send data.
That one also config both as input,

Been tried to change it , even from my first version of it.
, but still no luck.

That is very usual but this is what your datasheet says.

Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be
set in order to configure pins RC6/TX/CK and RC7/RX/DT
as the Universal Synchronous Asynchronous Receiver
Transmitter

But what is the meaning of set? It is not very clear. Set can mean set to zero or set to 1. The sentence does not seem to be well written at all.

Here is what mine says for my chip. It is VERY clear and is the way I have done it with every chip I have used.

- SPEN bit (RCSTA1<7>) must be set (= 1)
- TRISC<7> bit must be set (= 1)
- TRISC<6> bit must be cleared (= 0)

MCC supports your chip. Why aren't you using the code generated from it?

You still have not stated what is wrong.


 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
Have again been studing and comparing from online MCC.
This is from datasheet.

Setting the TXEN bit of the TX1STA register enables the


transmitter circuitry of the EUSART. Clearing the SYNC

bit of the TX1STA register configures the EUSART for

asynchronous operation. Setting the SPEN bit of the

RC1STA register enables the EUSART and

automatically configures the TX/CK I/O pin as an output.

If the TX/CK pin is shared with an analog peripheral, the


analog I/O function must be disabled by clearing the



corresponding ANSEL bit.


Here is the output from MCC online.
With my comments, as there is things i dont get.

Code:
 TRISx registers
    */
    TRISE = 0x07; // all in.  RE3 out(Reset) = Should be input if i am right?
    TRISA = 0xFF; // all out
    TRISB = 0xFF; // all out
    TRISC = 0x7F; // all in, except C7 out ( Should be oppesite )
    TRISD = 0xFF; // all out

    /**
    ANSELx registers
    */
    ANSELD = 0xFF;
    ANSELC = 0xBF; //all analog, except RC6 ?
    ANSELB = 0xFF;
    ANSELE = 0x07;
    ANSELA = 0xFF;
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
YESSSS

Finaly i got it working,
Connected PICKIT2 with UART Tools, and LOGIC Analyser, and found that data WAS transmitted with newest code,
But still HC-06 did not send anything,
Changed my terminal APP on phone, to one where i could choose ASCII and HEX.
My first APP did apperently support HEX, just ASCII,

Changed it to HEX and now data are comming in.
 
Top