Hello,
I'm using HC-05 bluetooth module with easyPIC7,
I can send TEXT to the mobile phone without a problem, but no receive
1- I'm using Bluetooth terminal to test
2- easyPIC7 with PIC18F45k22
3- MikroC pro 6
the code extremely simple:
///////////
char receive;
void main() {
ANSELC = 0; // Configure AN pins as digital I/O
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1) {
UART1_Write_Text("1"); //Working FINE
Delay_ms(1000);
if (UART1_Data_Ready() == 1) { // Never Happen, Im sure im sending data correctly "I tested the bluetooth with Arduino and everything working fine"
UART1_Write_Text("sthg received");
receive = UART1_Read();
UART1_Write(receive);
}
}
}
///////////////////////
I don't know what im missing here, to not make UART1_Data_Ready() work,
Thank you in advance,
Hasan
//
straight forward UART problem (UART1_Data_Ready) doesn't wor
-
- Posts: 47
- Joined: 11 Sep 2005 11:33
Re: straight forward UART problem (UART1_Data_Ready) doesn't
Sounds like a voltage mismatch issue. Are both the PIC and the HC05 running off 3.3V?
Regards, android
(User of MikroC Pro + mikroProg)
(User of MikroC Pro + mikroProg)
-
- Posts: 47
- Joined: 11 Sep 2005 11:33
Re: straight forward UART problem (UART1_Data_Ready) doesn't
Hi,
Thanks for replying, but i checked and its not the voltage, both running on 3.3,
Tx of the module connected to Rx RC7
Rx of the module connected to Tx RC6
There is a key pin in the hc05 module, im not connecting it to anything,
But also when i tested it with arduino, it works with arduino without it,
The module can send normally, i have a problem in receiving data from the mobile, the condition UART1_Data_Ready never happens, i dont know why
To be noted:
the module working fine with Arduino and PC via UART cable,
Any help will be appreciated,
Thanks for replying, but i checked and its not the voltage, both running on 3.3,
Tx of the module connected to Rx RC7
Rx of the module connected to Tx RC6
There is a key pin in the hc05 module, im not connecting it to anything,
But also when i tested it with arduino, it works with arduino without it,
The module can send normally, i have a problem in receiving data from the mobile, the condition UART1_Data_Ready never happens, i dont know why
To be noted:
the module working fine with Arduino and PC via UART cable,
Any help will be appreciated,
-
- Posts: 47
- Joined: 11 Sep 2005 11:33
Re: straight forward UART problem (UART1_Data_Ready) doesn't
I solved the problem, now its communicating perfectly...
Re: straight forward UART problem (UART1_Data_Ready) doesn't
Hi could you share how did you manage to fix the problem with UART1_Data_Ready() never happening?hasanabouali wrote:I solved the problem, now its communicating perfectly...
I have same problem at the moment.
Thanks, Tomek.
Edit: Solved the problem!
- It's a silly thing, set ANSD7_bit and TRISD7_bit (in my case) to 0 after executing UART1_Init(baud_rate) command to make sure the serial input pin(s) are set to digital inputs
Code: Select all
char data;
UART1_Init(56700);
TRISD7_bit = 0;
ANSD7_bit = 0;
Delay_ms(100);
// can read stuff now
while (1)
{
if (UART1_Data_Ready() == 1)
{
data = UART1_Read();
UART1_Write(data);
}
}
Re: straight forward UART problem (UART1_Data_Ready) doesn't
Thanks for posting your solution Tomek. So many people just disappear or never say how they solved the problem!
-
- Posts: 62
- Joined: 16 Apr 2011 14:13
Re: straight forward UART problem (UART1_Data_Ready) doesn't
JaHeretyk wrote:Hi could you share how did you manage to fix the problem with UART1_Data_Ready() never happening?hasanabouali wrote:I solved the problem, now its communicating perfectly...
I have same problem at the moment.
Thanks, Tomek.
Edit: Solved the problem!
- It's a silly thing, set ANSD7_bit and TRISD7_bit (in my case) to 0 after executing UART1_Init(baud_rate) command to make sure the serial input pin(s) are set to digital inputs
Code: Select all
char data; UART1_Init(56700); TRISD7_bit = 0; ANSD7_bit = 0; Delay_ms(100); // can read stuff now while (1) { if (UART1_Data_Ready() == 1) { data = UART1_Read(); UART1_Write(data); } }
Good to share, but from experience set RX as input
Code: Select all
TRISD7_bit = 1;
Never be afraid to try.
PICKit3 + MikroC Pro for PIC
DAQ with Ethernet -- Current project
PICKit3 + MikroC Pro for PIC
DAQ with Ethernet -- Current project
Code: Select all
TRISA = 0x00