How to interface 9s12c32 with HC06 bluetooth module?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to interface 9s12c32 with HC06 bluetooth module?

773 Views
yaoyao
Contributor I

I have the TX from the microcontroller connected to the RX of the Bluetooth module (across a voltage divider of 2k and 1k ohms to drop it down to 3.3V logic range), and the RX of the microcontroller to the TX of the module. I have SCI set with 9600 baud with 1 stop bit and zero parity bits. Placing a char on SCIDRL does not give the expected output (same as the char) on teraterm. Any help is appreciated!

0 Kudos
Reply
4 Replies

553 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

have you checked the signals by oscilloscope? How does it look like? We have this application note that describes how to connect 5V system to 3.3V:

http://www.freescale.com/files/microcontrollers/doc/app_note/AN2433.pdf

And I found simple example for echo test in my repository, see please below.

Regards,

Lukas

#include <hidef.h>  /* common defines and macros */
#include <mc9s12c32.h> /* derivative information */

#pragma LINK_INFO DERIVATIVE "mc9s12c32"

//==============================================================================

// SCI_ISR

//==============================================================================

#pragma CODE_SEG NON_BANKED

interrupt 20 void SCI_ISR(void)

{

  unsigned char scicr2,scisr1,sc0_data_in;

  scisr1 = SCISR1;                      //save status register actual status
  scicr2 = SCICR2;                      //save control register actual status

  //--- if receiver interrupt is enabled and corresponding interrupt flag is set

  if((scicr2 & SCICR2_RIE_MASK) && ((scisr1 & (SCISR1_OR_MASK | SCISR1_RDRF_MASK))))

   {

if(scisr1 & SCISR1_OR_MASK)         //if overrun error do nothing/something
  {
    (void)SCIDRL;                   //clear interrupt flag
    // do something
  }
else
  {
    sc0_data_in = SCIDRL;           //read received character + clear interrupt flag
  
    while(!SCISR1_TC);              //wait if transmission is in progress  
    SCIDRL = sc0_data_in;           //send back
  }

  }

}

#pragma CODE_SEG DEFAULT

//==============================================================================

// SCI_Init

//==============================================================================

void SCI_Init(void)

{

   //SCIBD = BUSCLK / (16*Baud rate) = 8000000 / (16*9600) = 52 = 0x34

  

   SCIBDH = 0x00;  //prescaller value 

   SCIBDL = 0x34;  //prescaller = 0x34

   SCICR1 = 0x44;

   SCICR2 = 0x2C;  //transmitter enable

}

//==============================================================================

// main

//==============================================================================

void main(void) {

 

  SCI_Init(); 

 

  EnableInterrupts;

  for(;;) {} /* wait forever */

  /* please make sure that you never leave this function */

}

0 Kudos
Reply

553 Views
yaoyao
Contributor I

First of all, happy holidays! I do not own an oscilloscope to test the pins. I tried your echo program and it turns out the it never gets interrupted, so I thought that the Bluetooth's TX pin may be malfunctioning. But disconnecting the Bluetooth module from the circuit and shorting its RX and TX pins gives the expected result (echo) on Teraterm. The serial pins work when I interfaced them with RS232 DB9. What other factors could contribute to this?

0 Kudos
Reply

553 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Well, from your description, everything point to Bluetooth chip. MCU is obviously working as expected. I would check the documentation for Bluetooth chip, it looks like it requires some settings or whatever...

Lukas

0 Kudos
Reply

553 Views
yaoyao
Contributor I

I will try to figure it out.

Thank you and happy new year!

0 Kudos
Reply