Serial Communication between Espruino - PIC16F628A #1488
Replies: 25 comments
-
Posted at 2015-06-01 by @gfwilliams Looks like you only have two wires? You'd need to connect RX, TX and GND - it's the same for most busses (Serial, SPI, I2C, OneWire, etc)... Thanks for attaching the picture though - it makes finding problems a lot easier :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-01 by fobus
Is this real? or are you kidding ? :) Yes, I have only two wires RX and TX. But there is a red-small jumber on the PIC's board. This is VDD of PIC. I think you don't mean this, you mean a GND for Serial communication. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-01 by @gfwilliams
No - some people just post up and say "it's not working!", and it makes a lot more difficult :) Yes, I mean ground for serial communications... I don't know where the orange and green wires go, but presumably it's to a bench supply that doesn't share the same GND as the computer's USB? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-01 by fobus Orange and gren comes direct from 5V adapter. And STM32F4 Board gets the power from USB. You are right they don't share the same GND. So, Board and PIC uses different power sources. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-01 by @gfwilliams Ok, so all you need to do is connect the two GNDs (STM32F4 GND and PIC GND) together and it should work... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-01 by DrAzzy Yeah, that'll do it. You always need a common ground. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-01 by fobus I think I'm still doing some thing wrong. Now I'm using a 5V source for both STM32F4 and PIC, but still getting random characters. I'm going to try a debugger to see what's happening inside of the pic and write the results here. Thanks for your helps. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-02 by @gfwilliams Do they each have the same baud rate set? Ok, the other thing you could do is to use a USB-TTL converter to connect straight to the PIC, to check that is doing what you want. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-02 by fobus Yes, all baut rates are 9600. OK, I'm going to try a USB-TTL converter. Thank you for your helps |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-02 by DrAzzy I notice the pic doesn't have a crystal. I don't know if PIC has this problem, but AVR chips running off internal clock sometimes fail at UART communication because the internal oscillator is so far off that the timing is wrong. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-02 by fobus @drazzy @gfwilliams I think it was not working because of some noise. You can see this video to understand why I am suspecting about noise : Attention : This video includes brain damaging English . As you can see this noise occurs at the half of the cable when I get closer my finger. I can touch the other half of cable. Isn't this interesting. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-02 by DrAzzy Do you have a decoupling cap on the PIC? This may well not be the problem either, but I've seen chips w/out decoupling cap do all kinds of crazy things. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-03 by @allObjects Do you have some wireless router, cordless phone, or other crazy RF thing goin on? A a CFL lamp that is not properly grounded, or dimmable,... It looks like your body is a transmitting antenna. Latter leads me to the questions: is there a radio station close by? Or heavy powerlines passing by? May you have to move into a Faraday cache or make your room one... ;-) This are all just wild guesses, but the behavior you experience is very interesting... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-03 by DrAzzy Could it be as simple as dodgy breadboard connections? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-03 by fobus @drazzy I don't use decoupling cap in this circuit. I'm going to try it. @allObjects, I could understand if my body is transmiting noise on circuit. But I can touch left side of the Cable. If my body transmiting noise, why it doesn't transmit to the left side of cable? Why it tranmits to only right side? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-05 by fobus This occurs only when I test it with my notebook. Works great on my friends notebook. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-05 by DrAzzy That's very strange... (the bit about it working with one computer, but not the other). Decoupling/bypassing: Any and every integrated circuit should have a 0.1uf ceramic capacitor between it's Vcc and Gnd pins, as close to the pin as possible, unless otherwise stated in the datasheet, otherwise they can do all sorts of crazy stuff. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-05 by @gfwilliams
Espruino has some capacitors built in, but if you haven't put anything on the PIC, that could do it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-06-06 by fobus Now, We could understand why this problem occurs. This is the exact reason; In my last post, I have told that this problem doesn't occurs on my friends notebook; Yes it didn't occur because we carried the curcuit near to his notebook and his notebook was working on battery. We have placed 1,2,3,4 and more decoupler on circuit. But it doesn't effect on this problem. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-20 by fobus Hello, I'm sorry to activate this thread again. After my last post, suddenly it worked with a 0.1uf ceramic capacitor. Then I had a break on this project for 2-3 monts. Now, I have created an other circuit as the same of last working one. But getting the same error. Now in my test results pic allways flooding CL-LF (Char 10 and Char 13). But when I put the circut 30 cm away from my notebook, it doesn't flood 10 and 13 char. Espruino board and pic connected to the same power source with the same ground. I have tried more than 10 capacitors, but result is the same. I can only guess that all my capacitors are broken. Tomorrow I'm going to buy new capacitors. Capacitors code is "104" I think I'm using the right one. Do you have any other idea? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-20 by @allObjects Something in your circuit works as a Wifi or other RF antenna... (assuming you use Wifi. It could alos be that your CPU clock is 'heard' quite 'loudly'... Open - or not strong enough pulled-up or pulled-down inputs, lousy connections, and lousy ground/GND connections can cause this issue... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-20 by DrAzzy I think the pic is reacting to noise, and sending CRLF sequences in response to said noise. Examine the code on the pic to see if there's any way that high impedance pins (inputs) transitioning randomly due to noise could make it do that. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-21 by @gfwilliams Could it be that the PIC's RX pin isn't connected to Espruino's TX pin? Or that Espruino's TX pin isn't configured as an output (Serial wasn't set up?). Sometimes people add a pull-up resistor to the serial lines to ensure that they stay in the high state before the Microcontroller boots up and sets the pin state correctly. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-25 by fobus I want to shoot my self, it was only about the LVP Fuse on pic. I have disabled the LVP Fuse and now it works great with only a 0.1uf ceramic capacitor. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-25 by @gfwilliams Ahh, the joys of embedded software :) Glad you got it working! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-06-01 by fobus
Hello,
I'm trying to communicate with PIC16F628A on serial. I have a STM32F4 Discovery Board intalled Espruino.
I have coded 16F628A with PicC. I can simulate the hex file in ISIS Proteus. It works perfect on ISIS Proteus. PIC's job is easy, reat the TX and write it to RX. So, work is a simple ECHO
Simulation works good, but problem occurs in real world. I'm writing the hex file to PIC and wiring it with Espruino board.
From Espruino I'm sending some chars over TX to the PIC but getting back random values on RX. You can find attached images how do I wire it.
I think this problem is not about Espruino, because when I plug boards TX and RX pins together Espruino can write and read wery well.
But I'm wondering about wiring or you may give me an idea.
Here is my Espruino code :
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions