Welcome, Guest

Author Topic: PIC32 MAXI WEB UART  (Read 2645 times)

ALFREDOSKY

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
PIC32 MAXI WEB UART
« on: September 09, 2014, 07:56:36 PM »
Hi all, i have been trying to run uart module, first i started with tx. This card came with code to achieve it. When i execute the routine to tx i watched the U1TXREG register(register/buffer that contains data to tx) was always empty. I saw too U1STA  register, and TRMT bit(bit 8) is always set on 1, it means "Transmit shift register is empty and transmit buffer is empty". I'm using MPLABX v2.00 IDE and XC32 v1.21 compiler, for programming and debugging i'm using REAL ICE. I put a breakpoint in tx line routine and transmission apparently runs.

i put this one to tx:
Code: [Select]
UartCommPrintSafe("\r\nWhy it not works?");
the UartCommPrintSafe routine is shown below:
Code: [Select]
void UartCommPrintSafe(char *str)
{
int len = strlen(str);

xSemaphoreTake(xMutexUartComm, portMAX_DELAY);

while(len) {
int written;

written = UartCommWrite(str, len);
str += written;
len -= written;

if(len)
vTaskDelay(1);
}

xSemaphoreGive(xMutexUartComm);
}


UartCommWrite is shown below:
Code: [Select]
int UartCommWrite(char *pData, int len)
{
int count = 0;

while(len--) {
if( (txBufHead == txBufTail) && !txBufEmptyFlag) {
break;
}
else {
txBufEmptyFlag = FALSE;
txBuffer[txBufHead++] = *pData++;
if(txBufHead >= TX_BUFFER_SIZE)
txBufHead = 0;

count++;
}
}

return count;
}

This card runs with FreeRTOS, taksIO run UartCommDoWork() boolean routine that return TRUE if some work done and FALSE if called without doing smth useful(taken from the description of the routine). I take the signal from db9 conector, TX and RX pins, for now, only TX pin was tasted. this is for OLIMEX team but if someone had this issue and had worked with uart using this card, please help me to solve it.  :-\

ALFREDOSKY

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Re: PIC32 MAXI WEB UART
« Reply #1 on: September 10, 2014, 01:14:24 AM »
Answering to myself...I tasted rs232 pins with an oscilloscope and i didnĀ“t get any signal from TX pin, so i moved to UEXT1 conector and guess why?? i get the signal in pin3...so i think it will work properly in the future ;D...but i realize i will need the GND pin, so i'm a little confuse with this, my card will transmit to dspic30f microcontroller, this mcu works with 5v and olimex card works with 12v...so...should i join these two grounds? or it is not necessary?  :-\

JohnS

  • Hero Member
  • *****
  • Posts: 1723
  • Karma: +33/-48
Re: PIC32 MAXI WEB UART
« Reply #2 on: September 10, 2014, 02:05:11 AM »
Be careful.  Joining Gnd if they are just Gnd is OK.  Any 12V/5V/3.3V signals need proper circuits.  Otherwise, damage is likely.

If you have any -12V (RS232) do not connect them to any pin that expects a TTL or the like signal.  You need a proper circuit.

John

ALFREDOSKY

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
Re: PIC32 MAXI WEB UART
« Reply #3 on: September 10, 2014, 07:34:35 PM »
Hi John S, thanks for reply; i have been thinking that is necessary ground 'signal', if we got two cards with different power sources and with 50 meters distance between them, we need a reference for RX and TX signal for both cards. the wiring must include TX,RX and GND, and join both two ground in some place(to one side of communication).I think this is right, but i saw other cases when GND 'signal' wasn't used. i don't know why!