Hello, I am working in mdk5. For my application I am writting code for RS485. While debugging I found that my FCR register is not loading its value. The code I have written is show below. void uart_rs485(void) { SCU_PinConfigure(2,3, SCU_CFG_MODE_FUNC2);// p2_3 for U3_TXD SCU_PinConfigure(2,4, SCU_CFG_MODE_FUNC2);// p2_4 for U3_RXD GPIO_SetDir(4,11,GPIO_DIR_OUTPUT);// Set GIO_B1_RS485_DIR as output
LPC_USART3->LCR = 0x83;// Line Control Register LPC_USART3->FCR =0x07;//FIFO buffer LPC_USART3->FDR =0;// Fractional Divide LPC_USART3->DLM =0;//Divide Latch MSB LPC_USART3->DLL =98;//Divide Latch LSB LPC_USART3->LCR =0x03;//Disable DLAB
} void uart_rs485_transmit(void) { GPIO_PinWrite(4,11,1);//Making Transmit Enable high if(LPC_USART3->LSR & 0x20) { LPC_USART3->THR = 83; } }
void uart_rs485_receive(void) { GPIO_PinWrite(4,11,0);//Receive Enable a = LPC_USART3->RBR; } Please help me in this flow. Thank you in advance
KINDLY REPLY ME AS SOON AS POSSIBLE BECAUSE THE REQUIREMENT IS CRITICAL.
www.catb.org/.../smart-questions.html
Too critical for you to bother to follow the simple, clearly-stated instructions on how to post source code, then?
www.danlhenry.com/.../keil_code.png
There's one line that's not right:
LPC_USART3->LCR = 0x83;// Line Control Register LPC_USART3->FCR =0x07;//FIFO buffer
You seem to have code that's commented out.
It looks like that's not the only line like it.
If you want code to be compiled, you have to make sure it's not commented out.
PLEASE SORT OUT THIS PROBLEM AND GET BACK TO US. IT IS IMPERATIVE THAT YOU GET IT TO US AS SOON AS POSSIBLE. IT IS CRITICAL.
WHEN YOUR CHEQUE CLEARS YOUR APPLICATION WILL BE PROCESSED, THERE WILL BE NO EXCEPTIONS...
Hello, The code as follows. Sorry for the inconvenience. void uart_rs485(void) { SCU_PinConfigure(2,3, SCU_CFG_MODE_FUNC2);// p2_3 for U3_TXD SCU_PinConfigure(2,4, SCU_CFG_MODE_FUNC2);// p2_4 for U3_RXD GPIO_SetDir(4,11,GPIO_DIR_OUTPUT);// Set GIO_B1_RS485_DIR as output
void uart_rs485_receive(void) { GPIO_PinWrite(4,11,0);//Receive Enable a = LPC_USART3->RBR; }
Hi Rajesh, I have a request to you. Please read the each and every line of the answers you get here. If it is not understandable in first read then read it again and again until it is completely making sense to you. yes sometimes it is difficult for us because of the too much english they use in the answers ;).
So from the first response your questions Andy,
Whoever trying to help you here did not find your post as well presented as they like every professionals do. Again too much expectations on us right.. Your code look like you have a map on scribbles. So he is trying to help you to improve in that area. It is not technically solving your URGENT problem. But believe me you will be needing that anytime soon in your career.
Next, from the second answer you got from B Carutt, He asking you to uncomment an important line which seems to directly linked to your problem statement. But he also asking you to check the criticality of all other commented lines because he thinks those commented lines seem to be more than just comments.
Next, From the third answer you got from Westonsupermare Pier, I do not understand the meaning of the sarcasm. If it same to you then just ignore that answer.
Next, from your response, you did some clean up in your copy pasted code. And added some proper(I assume) register settings. But you failed to mention many information here. They do not know what is the result after you modified the code such as 1.Even after your code change still not able to load the FCR reg? and many more may be (i.e micro, hardware info, details of testing method etc).
And a final note from me, in this forum you do not get the right answers always but always learn something if you're willing. I was once in your shoes.
You still have not followed the simple, clearly-stated instructions on how to post source code!
Look at the picture: www.danlhenry.com/.../keil_code.png
You have also not stated what chip you are using.
sorry Carrut. The code id given here. I think you can get it now.
void uart_rs485(void) { SCU_PinConfigure(2,3, SCU_CFG_MODE_FUNC2); SCU_PinConfigure(2,4, SCU_CFG_MODE_FUNC2); GPIO_SetDir(4,11,GPIO_DIR_OUTPUT); LPC_USART3->LCR = 0x83; LPC_USART3->FCR =0x07; LPC_USART3->FDR =0; LPC_USART3->DLM =0; LPC_USART3->DLL =98; LPC_USART3->LCR =0x03;
The chip I am using is LPC1857
void uart_rs485(void) { SCU_PinConfigure(2,3, SCU_CFG_MODE_FUNC2); SCU_PinConfigure(2,4, SCU_CFG_MODE_FUNC2); GPIO_SetDir(4,11,GPIO_DIR_OUTPUT); LPC_USART3->LCR = 0x83; LPC_USART3->FCR =0x07; LPC_USART3->FDR =0; LPC_USART3->DLM =0; LPC_USART3->DLL =98; LPC_USART3->LCR =0x03; } void uart_rs485_transmit(void) { GPIO_PinWrite(4,11,1);//Making Transmit Enable high if(LPC_USART3->LSR & 0x20) { LPC_USART3->THR = 83; } } void uart_rs485_receive(void) { GPIO_PinWrite(4,11,0);//Receive Enable a = LPC_USART3->RBR; }
So you really don't believe in indentation for 'C' source code?
Sorry Neil, What you meant by this identation
Seriously?! You've never heard of indentation in the context of writing source code?!
en.wikipedia.org/.../Indent_style
It is an (almost?) universal way of laying out the text to make the structure clear & easy to read.
For example:
void uart_rs485_transmit(void) { GPIO_PinWrite(4,11,1); //Making Transmit Enable high if(LPC_USART3->LSR & 0x20) { LPC_USART3->THR = 83; } }
K. I am following the above told identation.
Hello, Let me know about the PCLK value that should be given for UART communication. How to assign PCLK in mdk5
Hi Rajesh check my message if it is helpful in anyway.
www.keil.com/.../ In the above link, they have given enough examples to start a product company. There is no direct RS-232 or RS-485 example programs. But even blink sample will have UART and/or LCD as a basic information display medium.
So with the given example you do not have to configure anything for UART(Including PCLK). But note that those examples targeted for MCB1800 board. You may have to modify pin configurations for your board.
I would suggest you to verify your UART functionalists first before testing your hardware dependent RS485 functionalists.
Hi Dharmaraj, Thanks a lot.I will check that link you have shared.