Hello,
For the next problem i need the input from this forum again
Situation:
A PIC16F628A or 16F690 and a BC04 bluetooth module.
I've made a simple test program for reading and sending some data to my smartphone.
Therefore i've downloaded different applications which can send and recieve data via bluetooth.
Finaly i send max one byte each time.
Sending data from PIC to BC04 works without any problem. I can read data at my smartphone.
Retrieving data from the smartphone via the BC04 is not working.
I can see a short flickering at the led connected to the rx line, but the rx-buffer seems to stay empty.
At first i used the hserin command (ignoring the PIR1.RCIF bit, which i want to use at a later stadium).
The program is waiting for data, but it doesn't detect new data.
At second i've tried the hserget command, but it doesn't matter.
When i use the software UART (serin) i can see some data, but it is not stable.
I've attached the code with the HSERIN command. Do I need some pull-up or pull down resistors?
Can it be possible that i need some more settings for UART communication?
I prefer the HSERIN command for my final program with the condition that PIR1.RCIF = true.
So in my program i will write:
IF PIR1.RCIF = true THEN
Hserin bt_value 'bt_value is a variabele of datatype byte
endif
Any suggestions why restrieving serial data doesn't work?
testcode:
For the next problem i need the input from this forum again
Situation:
A PIC16F628A or 16F690 and a BC04 bluetooth module.
I've made a simple test program for reading and sending some data to my smartphone.
Therefore i've downloaded different applications which can send and recieve data via bluetooth.
Finaly i send max one byte each time.
Sending data from PIC to BC04 works without any problem. I can read data at my smartphone.
Retrieving data from the smartphone via the BC04 is not working.
I can see a short flickering at the led connected to the rx line, but the rx-buffer seems to stay empty.
At first i used the hserin command (ignoring the PIR1.RCIF bit, which i want to use at a later stadium).
The program is waiting for data, but it doesn't detect new data.
At second i've tried the hserget command, but it doesn't matter.
When i use the software UART (serin) i can see some data, but it is not stable.
I've attached the code with the HSERIN command. Do I need some pull-up or pull down resistors?
Can it be possible that i need some more settings for UART communication?
I prefer the HSERIN command for my final program with the condition that PIR1.RCIF = true.
So in my program i will write:
IF PIR1.RCIF = true THEN
Hserin bt_value 'bt_value is a variabele of datatype byte
endif
Any suggestions why restrieving serial data doesn't work?
testcode:
Code:
Define CONFIG = 0x3f50
Define CLOCK_FREQUENCY = 4
AllDigital
Define LCD_BITS = 4 'allowed values are 4 and 8 - the number of data interface lines
Define LCD_DREG = PORTA
Define LCD_DBIT = 0 '0 or 4 for 4-bit interface, ignored for 8-bit interface
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 6
Define LCD_EREG = PORTA
Define LCD_EBIT = 7
Define LCD_COMMANDUS = 100 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 50 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 50 'delay used by LCDINIT, default value is 100
'the last three Define directives set the values suitable for simulation; they should be omitted for a real device
Dim bt(5) As Byte
ConfigPin PORTB.1 = Input
ConfigPin PORTB.2 = Output
Dim teller As Word
Lcdinit 1 'initialize LCD module; cursor is blinking
Lcdcmdout LcdClear 'clear LCD display
Lcdout "boot up"
Hseropen 9600
loop:
teller = teller + 1
WaitMs 500
bt(5) = bt(4)
bt(4) = bt(3)
bt(3) = bt(2)
bt(2) = bt(1)
bt(1) = bt(0)
Hserin bt(0)
Lcdcmdout LcdClear
Lcdout #bt(0), "_", #bt(1), "_", #bt(2), " " 'text for the line 1
Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
Lcdout #bt(3), "_", #bt(4), "_", #bt(5), " " 'formatted text for line 2
WaitMs 1000
Hserout #teller
Goto loop 'loop forever
Last edited: