- Joined
- Jan 22, 2008
- Messages
- 53,300
- Helped
- 14,795
- Reputation
- 29,877
- Reaction score
- 14,324
- Trophy points
- 1,393
- Location
- Bochum, Germany
- Activity points
- 301,872
This is your configuration. I decoded it to show that there's no problem of watchdog reset, as previously suspected by others.I really don't understand, my setting is the same as shown but it still doesn't work.
This is your configuration. I decoded it to show that there's no problem of watchdog reset, as previously suspected by others.
But I didn't claim that your code "works". I already mentioned that it might be inappropriate for the CNC data you are receiving and asked for an example.
UART_Read_Text()
uart1_read_text(receive,'F',65);
uart1_read_text(receive,"F",65);
Mods please don't delete this post. The OP has requested for code and hence I am posting this project. The OP is using mikroC PRO PIC and hence I have modified his project and posting it.
The changes made are:
OP code usedCode:UART_Read_Text()
function (non interrupt based) to receive serial data.
I am using a Serial receive interrupt to receive serial data. It receives 64 characters and then sets a flag and disables interrupts. The flag which is set is processFlag.
It is tested if this flag is set in main loop. If it is set then processing is done. The received ascii characters '0' and '1' in the array are converted to 0 and 1 integers and then assigned to PORTA with a delay of 50 ms after assigning each value. After all the 0 and 1 bits are sent to PORTA it prints 'F' on Serial terminal and then gets ready for next cycle.
In your original code this is the only mistake I found.
Code:uart1_read_text(receive,'F',65);
It should be
Code:uart1_read_text(receive,"F",65);
The delimiter F should be a string and not a charcater. The mikroC help files says so.
It could also be a h/w issue. We know nothing about schematic and PCB layout. Probably, some capacitors missing. Or even whole schematic have to be reviewed.
I'm not surprised that it doesn't work.please consider my schematic pleaseView attachment 127642
@EasyRider
I think he said it works but works three times everytime repeateadly.
Really hard to hear a clear answer. In post #25 you claimed no answer at all.yes it repeating for 3 times!
How to fix that?Really hard to hear a clear answer. In post #25 you claimed no answer at all.
Anyway, did you already fix the character array overrun problem?
yes I did, the code that you gave me can not compiledid you tried my improvement in the code is posted in #12? And please be clear actually what problem your facing? last posts depicts that you were facing problem in receiving chars and now you are saying the program runs three times? what is the problem actually?
PIE1_bit=1
PIE1_bit=1;
my problem is the pic is repeating the program for 3 times without any control. as the code I have shown. I send string from computer by serial port the string contain 65 character include "F" in the end of string is to tell pic that sending is finish. after pic execute program it send "F" back to computer to request next string. in this case I sent the first string pic executed send "F" back to computer, but it doesn't stop, it repeated for 3 times.
Add a semicolon.
Code:PIE1_bit=1;
Maybe the CR + LF that your mikroC PRO PIC's USART Terminal is sending is causing the receive buffer to overflow and causing the problem. I can't guess. If PIC resets then buffer gets cleared and I don't know how it can run the data 3 times.
Did you try my project. If not, test it and reply.
RCIF_bit = 0;
it can not compile in PIE1_bit=1;
PEIE_bit = 1;
if(receive[index - 1] == '\r') {
while(receive[i] != '\r')
Thanks very much to every one it works, I change the 'F' to "F" in receive.Hi
Here is a better version of the project. Test it in hardware and reply. I have tested this in Proteus and it works fine. The changes made are Serial Interrupt is used to receive UART data and Timer Interrupt is used to send data to CNC Machine. All blocking codes are removed. You can do other things in while(1) loop if needed. This will not affect the functioning of the device.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?