UART_Write Peoblem

Discussion on projects that are created by users and posted on mikroElektronika website.
Author
Message
jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: UART_Write Peoblem

#16 Post by jayanthd » 26 Aug 2015 14:46

burakerguder wrote:
jayanthd wrote:Answer in detail what you are trying to do and what data you are sending from PC.
My real project is communication between two PIC. I am desinging a board to control HF Generator. First i designed a board and connected the generator and nothing happened. Then i connect the board to the pc and i decided that uart_write command does not work properly. As you see in the photo i have a lcd screen on the board. When i send data from pc to pic, board takes it and shows the data on the screen however when i use uart1_write command there is nothing happens on the terminal. If the connections are wrong, lcd can not show the received data. what i am doing wrong i could not find it yet :S

UART_Write() is used like this.

Code: Select all

UART1_Write('A');
So, you are using mikroE Serial Terminal Software. It sends data as ascii characters. I am reading your device datasheet. I will make a code for you which uses Serial Interrupt to receive data. Give me a day.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

burakerguder
Posts: 14
Joined: 07 Apr 2015 15:01

Re: UART_Write Peoblem

#17 Post by burakerguder » 26 Aug 2015 14:51

jayanthd wrote:
burakerguder wrote:
jayanthd wrote:Answer in detail what you are trying to do and what data you are sending from PC.
My real project is communication between two PIC. I am desinging a board to control HF Generator. First i designed a board and connected the generator and nothing happened. Then i connect the board to the pc and i decided that uart_write command does not work properly. As you see in the photo i have a lcd screen on the board. When i send data from pc to pic, board takes it and shows the data on the screen however when i use uart1_write command there is nothing happens on the terminal. If the connections are wrong, lcd can not show the received data. what i am doing wrong i could not find it yet :S

UART_Write() is used like this.

Code: Select all

UART1_Write('A');
So, you are using mikroE Serial Terminal Software. It sends data as ascii characters. I am reading your device datasheet. I will make a code for you which uses Serial Interrupt to receive data. Give me a day.

Thanks for your help, I would be very grateful.

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: UART_Write Peoblem

#18 Post by jayanthd » 26 Aug 2015 14:55

See the image. You are using pins 100 and 101 in the Remappable() functions but in the device it has only 100 pins. There is no pin 101. Also you had configured TRISF for UART but pin 100 belongs to PORTE. So, you should configure TRISE.

This is wrong.

Code: Select all

if(uart_rd) {
          Lcd_Chr(row,col,uart_rd);

          if(uart_rd == 17){
              Lcd_Cmd(_LCD_CLEAR);
              col = 1;
              row = 1;
          }
You can't send integer value and also ascii characters from PC to PIC24 and test it. Send only acii chacaters to be printed on LCD. In code increment the row and col values when ever a character is received. Rest row to 1 or 2 and col to 1 when they reach their max values.
Attachments
UART.png
UART.png (71.17 KiB) Viewed 4532 times
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

burakerguder
Posts: 14
Joined: 07 Apr 2015 15:01

Re: UART_Write Peoblem

#19 Post by burakerguder » 26 Aug 2015 15:08

jayanthd wrote:See the image. You are using pins 100 and 101 in the Remappable() functions but in the device it has only 100 pins. There is no pin 101. Also you had configured TRISF for UART but pin 100 belongs to PORTE. So, you should configure TRISE.

This is wrong.

Code: Select all

if(uart_rd) {
          Lcd_Chr(row,col,uart_rd);

          if(uart_rd == 17){
              Lcd_Cmd(_LCD_CLEAR);
              col = 1;
              row = 1;
          }
You can't send integer value and also ascii characters from PC to PIC24 and test it. Send only acii chacaters to be printed on LCD. In code increment the row and col values when ever a character is received. Rest row to 1 or 2 and col to 1 when they reach their max values.
When i check the datasheet, rp100 pin seems rf4 and rp101 pin seems rf5. An there is not a problem about printing a character on the lcd. I can not send anything to pc or another pic from my board.
Attachments
IMG_1788.JPG
IMG_1788.JPG (628.94 KiB) Viewed 4530 times

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: UART_Write Peoblem

#20 Post by jayanthd » 26 Aug 2015 15:24

Yes, you are right regarding the pin numbers. I think generating 9600 bps baudrate when clock is 140 MHz will genarate a large percentage of error in the baudrate. Try using higher baudrate so that error will be less. Remember to set baudrate in PC exactly as in code.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

burakerguder
Posts: 14
Joined: 07 Apr 2015 15:01

Re: UART_Write Peoblem

#21 Post by burakerguder » 26 Aug 2015 15:30

jayanthd wrote:Yes, you are right regarding the pin numbers. I think generating 9600 bps baudrate when clock is 140 MHz will genarate a large percentage of error in the baudrate. Try using higher baudrate so that error will be less. Remember to set baudrate in PC exactly as in code.
Nope it did not work to set the baude rate higher, besides i have to set it 9600 becuse hf generator works with 9600 baude rate :S

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: UART_Write Peoblem

#22 Post by jayanthd » 26 Aug 2015 15:47

Open a ticket and ask for support. I will try to make a code for you using Serial Interrupt for receiving data.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

burakerguder
Posts: 14
Joined: 07 Apr 2015 15:01

Re: UART_Write Peoblem

#23 Post by burakerguder » 26 Aug 2015 15:49

jayanthd wrote:Open a ticket and ask for support. I will try to make a code for you using Serial Interrupt for receiving data.
Ok i will do it and thanks for your help again.

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: UART_Write Peoblem

#24 Post by jayanthd » 31 Aug 2015 13:54

burakerguder wrote:
jayanthd wrote:Open a ticket and ask for support. I will try to make a code for you using Serial Interrupt for receiving data.
Ok i will do it and thanks for your help again.
Please show your circuit connections. I need the schematic.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

burakerguder
Posts: 14
Joined: 07 Apr 2015 15:01

Re: UART_Write Peoblem

#25 Post by burakerguder » 31 Aug 2015 13:56

jayanthd wrote:
burakerguder wrote:
jayanthd wrote:Open a ticket and ask for support. I will try to make a code for you using Serial Interrupt for receiving data.
Ok i will do it and thanks for your help again.
Please show your circuit connections. I need the schematic.
Attachments
IMG_1857.JPG
IMG_1857.JPG (406.8 KiB) Viewed 4515 times

Post Reply

Return to “User Projects”