Pic18 and RN42 bluetooth communication problem using UART


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,635

    Default Re: Pic18 and RN42 bluetooth communication problem using UART

    How should I enter ints 16 bit signed values? like following?
    to send 10
    in little_endian format
    Hserout [10,0]

    or big_endian format
    Hserout [0,10]

    not sure how arduinos go about it they could be big or little endian

    if your values can be negative then you need to pay close attention to your calcs pbp uses unsigned math



    New Code with config:
    there is no config there
    pbp default config for pic18f24j50 is

    Code:
    #CONFIG
      CONFIG  WDTEN = ON
      CONFIG  PLLDIV = 5
      CONFIG  STVREN = ON
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CPUDIV = OSC1
      CONFIG  CP0 = OFF
      CONFIG  OSC = HSPLL
      CONFIG  T1DIG = ON
      CONFIG  LPT1OSC = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  WDTPS = 512
      CONFIG  DSWDTOSC = INTOSCREF
      CONFIG  RTCOSC = T1OSCREF
      CONFIG  DSBOREN = ON
      CONFIG  DSWDTEN = ON
      CONFIG  DSWDTPS = G2
      CONFIG  IOL1WAY = ON
      CONFIG  MSSP7B_EN = MSK7
      CONFIG  WPFP = PAGE_0
      CONFIG  WPEND = PAGE_WPFP
      CONFIG  WPCFG = OFF
      CONFIG  WPDIS = OFF
    #ENDCONFIG
    which expects an external xtal



    DEFINE OSC 16

    is just a compiler directive used for compile time timing calculations , it does nothing else

    to use the internal osc the config words need to be set appropriately
    such as
    CONFIG OSC = INTOSC

    or

    CONFIG OSC = INTOSCPLL

    and
    CONFIG PLLDIV needs to match

    along with

    CONFIG CPUDIV which need to match

    read the osc section of the data sheet
    Warning I'm not a teacher

  2. #2
    Join Date
    May 2016
    Posts
    33

    Default Re: Pic18 and RN42 bluetooth communication problem using UART

    Thanks alot! I will try that.

    Do I need to set OSCCON and OSCTUNE registers as well if I am using internal oscillator? I am a bit confused about Frequency Tuning bit of OSCTUNE register.How you get to 16MHz from 96 MHz PLL?

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,635

    Default Re: Pic18 and RN42 bluetooth communication problem using UART

    for 16mhz
    Code:
    #CONFIG
      CONFIG  WDTEN = ON
      CONFIG  PLLDIV = 2
      CONFIG  STVREN = ON
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CPUDIV = OSC3_PLL3
      CONFIG  CP0 = OFF
      CONFIG  OSC = INTOSCPLL
      CONFIG  T1DIG = ON
      CONFIG  LPT1OSC = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  WDTPS = 512
      CONFIG  DSWDTOSC = INTOSCREF
      CONFIG  RTCOSC = T1OSCREF
      CONFIG  DSBOREN = ON
      CONFIG  DSWDTEN = ON
      CONFIG  DSWDTPS = G2
      CONFIG  IOL1WAY = ON
      CONFIG  MSSP7B_EN = MSK7
      CONFIG  WPFP = PAGE_0
      CONFIG  WPEND = PAGE_WPFP
      CONFIG  WPCFG = OFF
      CONFIG  WPDIS = OFF
    #ENDCONFIG
    
    OSCTUNE.6=1  ; pll enable
    Code:
    8mhz   -----/2 --= 4---pll--= 96 -/2 = 48  ------/3--  =   16    
    inc osc   pll pre               pll            cpu div
    Last edited by richard; - 31st May 2016 at 10:16. Reason: white space is nearly impossible
    Warning I'm not a teacher

  4. #4
    Join Date
    May 2016
    Posts
    33

    Default Re: Pic18 and RN42 bluetooth communication problem using UART

    I got it running using external oscillator but bluetooth doesn't pickup the commands..

    Any idea? even
    Code:
    Hserout [dec 10]
    doesn't work.

  5. #5
    Join Date
    May 2016
    Posts
    33

    Default Re: Pic18 and RN42 bluetooth communication problem using UART

    Actually It's working using what you suggested.

    Code:
    Hserout [10,0]
    Thanks alot!

Similar Threads

  1. usart-bluetooth problem
    By murat44 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 5th February 2015, 18:00
  2. Communication using a Bluetooth module
    By Balachandar in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd November 2013, 08:56
  3. uart problem
    By OYMYAKON in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th March 2011, 11:52
  4. Bluetooth SKKCA communication failure
    By Rameesh in forum Bluetooth
    Replies: 7
    Last Post: - 23rd June 2008, 13:32
  5. Pic18 Syntax problem
    By Philip Biebach in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th January 2006, 06:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts