X
RSS YouTube LinkedIn Twitter XCore IRC

Search




Post new topic Reply to topic   [ 15 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Apr 16, 2012 9:27 pm 
Joined: Tue Apr 03, 2012 1:35 pm
Posts: 10
Hello,

I'm been also having some trouble with the simple uart module. I've modified the uart_back2back code so it would just listen to incoming transmission from a Arduino (simulating a sensor I would like to connect to the xmos)
Here the modified xmos code:
Code:
// Copyright (c) 2011, XMOS Ltd, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>

#include <xs1.h>
#include <platform.h>
#include "uart_rx.h"
#include "uart_tx.h"
#include <print.h>

void forward(chanend uartTX, chanend uartRX)
{
  uart_rx_client_state rxState;
  unsigned char rcvbuffer[26];
  unsigned char byte;
  int i;
  unsigned int gotest;
  gotest=1;
  byte=0;
  uart_rx_init(uartRX, rxState);
  while(gotest) {
   // printstr("Echo : ");

    for(i=0;i<13;i++) {
      rcvbuffer[i] = uart_rx_get_byte(uartRX, rxState);
    }
    for(i=0;i<13;i++) {
      printchar(rcvbuffer[i]);
    }
    //printstr(" done\n");
  }
  printstr("Test Completed\n");
}

//buffered in port:1 rx = on stdcore[0] : XS1_PORT_1A;
//out port tx = on stdcore[0] : XS1_PORT_1B;
buffered in port:1 rx = on stdcore[0] : XS1_PORT_1G;
out port tx = on stdcore[0] : XS1_PORT_1H;


#define BAUD_RATE 115200

#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

#pragma unsafe arrays
int main() {
  chan chanTX, chanRX;
  par {
    on stdcore[0] : {
      unsigned char tx_buffer[64];
      unsigned char rx_buffer[64];
      tx <: 1;
      printstr("Listening...\n");
      par {
        uart_rx(rx, rx_buffer, ARRAY_SIZE(rx_buffer), BAUD_RATE, 8, UART_TX_PARITY_NONE, 1, chanRX);
        uart_tx(tx, tx_buffer, ARRAY_SIZE(tx_buffer), BAUD_RATE, 8, UART_TX_PARITY_NONE, 1, chanTX);
      }
    }
    on stdcore[0] : {
      forward(chanTX, chanRX);
    }
  }
  return 0;
}


Here is the Arduino test Code :
Code:
void setup() {
   
    Serial.begin(115200);
}

void loop() {
   
    Serial.print("Hello World!\n");
 // delay(5);
 


}


There is no problem if I keep the delay around 50 milisec but if I lower it, I start getting errors. I'M I doing something wrong?

Thanks

Alex

(P.s. I moved this post from the other one since I felt It was in the wrong section)


Top
Offline Profile View all posts by this user  
 
PostPosted: Mon Apr 16, 2012 10:29 pm 
User avatar
XCore Moderator
Joined: Thu Dec 10, 2009 6:56 pm
Posts: 545
The print statements are using JTAG for printing to the console on the host.
During printing the entire core can be halted, this means that the UART RX thread can be halted while the other thread is printing, hence the loss of data.

For real-time non-intrusive printing you can use the print functionality of Xscope (only works on XS1-L) or use the UART lines on the XTAG2 adapter, or implement another UART and use a RS-232 connection to the host computer. You can also create a large buffer and store more lines until it is ok to print, if that fits the case.


Top
Offline Profile View all posts by this user  
 
PostPosted: Fri Apr 20, 2012 7:50 pm 
Joined: Tue Apr 03, 2012 1:35 pm
Posts: 10
Hi,

Thanks for the quick reply. I'm trying to use the print function with the Xscope since I am using the XK-1A board but I'm having some trouble. I used using the Debug-with-printf-in-real-time(X1093C) pdf as a guide and made the following changes to my code :
Code:
// Copyright (c) 2011, XMOS Ltd, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>

#include <xs1.h>
#include <stdio.h>
#include <xscope.h>
#include <platform.h>
#include "uart_rx.h"
#include "uart_tx.h"
//#include <print.h>



void forward(chanend uartTX, chanend uartRX)
{
  uart_rx_client_state rxState;
  unsigned char rcvbuffer;
  unsigned char byte;
  int i;
  unsigned int gotest;
  gotest=1;
  byte=0;
  uart_rx_init(uartRX, rxState);
  while(gotest) {

      rcvbuffer = uart_rx_get_byte(uartRX, rxState);

  }
}


void xscope_user_init ( void ) {
   xscope_register(0,XSCOPE_CONTINUOUS, "Continuous Value 1", XSCOPE_UINT, "Value") ;
   xscope_config_io(XSCOPE_IO_BASIC);
}


buffered in port:1 rx = on stdcore[0] : XS1_PORT_1G;
out port tx = on stdcore[0] : XS1_PORT_1H;

#define BAUD_RATE 115200

#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

#pragma unsafe arrays
int main() {



  chan chanTX, chanRX;


  par {
    on stdcore[0] : {
      unsigned char tx_buffer[64];
      unsigned char rx_buffer[64];

      tx <: 1;
      printf("Test Start...\n");
      par {
        uart_rx(rx, rx_buffer, ARRAY_SIZE(rx_buffer), BAUD_RATE, 8, UART_TX_PARITY_NONE, 1, chanRX);
        uart_tx(tx, tx_buffer, ARRAY_SIZE(tx_buffer), BAUD_RATE, 8, UART_TX_PARITY_NONE, 1, chanTX);
      }
    }
    on stdcore[0] : {

      forward(chanTX, chanRX);
    }
  }
  return 0;
}


Unfortunately I'm unable to build the project.
My getting this error
Code:
**** Build of configuration Debug for project Oronos_Uart ****

xmake CONFIG=Debug all
Creating dependencies for  Oronos_Uart.xc
Compiling  Oronos_Uart.xc
"Updating eclipse config"
Using modules: module_uart_rx module_uart_tx
Creating Oronos_Uart_Debug.xe
../src/Oronos_Uart.xc: Error: L00067 Undefined reference to 'xscope_config_io'
../src/Oronos_Uart.xc: Error: L00067 Undefined reference to 'xscope_register'
xmake[1]: *** [bin/Debug/Oronos_Uart_Debug.xe] Error 1
xmake: *** [bin/Debug/Oronos_Uart_Debug.xe] Error 2


Any help would be greatly appreciated.

Alexandre Borowczyk


Top
Offline Profile View all posts by this user  
 
PostPosted: Fri Apr 20, 2012 8:01 pm 
User avatar
XCore Moderator
Joined: Thu Dec 10, 2009 6:56 pm
Posts: 545
I think you may have to tick a box somewhere that you want to use xscope.
The problem is that the xscope library is not linked against your application.
I do not have experience with xscope projects in combination with the XDE.


Top
Offline Profile View all posts by this user  
 
PostPosted: Sat Apr 21, 2012 3:41 pm 
Joined: Tue Apr 03, 2012 1:35 pm
Posts: 10
Hello,

Yes it's seems this way. I've tried copying my code in the app_xscope_continuous files and it's compile without any problem and works! I was also wondering where can I find some info on the uart_moduale, specially on how the buffer works and what happens when it's full. It's seem that I my case, the programme crashed.

Thanks

Alexandre


Top
Offline Profile View all posts by this user  
 
PostPosted: Sun May 06, 2012 2:19 pm 
Joined: Tue Apr 03, 2012 1:35 pm
Posts: 10
Hi,

I'm looking to use 6 pins for a Uart implementation. how should I processed so I dont clog 6 thread? Also did anyone find out how to include the scope, so far I've been using a scope demo file as a host for my program.

Thanks

Alex


Top
Offline Profile View all posts by this user  
 
PostPosted: Sun May 06, 2012 3:36 pm 
User avatar
XCore Moderator
Joined: Thu Dec 10, 2009 6:56 pm
Posts: 545
Alexb wrote:
Hi,

I'm looking to use 6 pins for a Uart implementation. how should I processed so I dont clog 6 thread? Also did anyone find out how to include the scope, so far I've been using a scope demo file as a host for my program.

Thanks

Alex


You may want to take a look at this: https://github.com/xcore/sc_multi_uart
What do you mean with scope? Xscope?


Top
Offline Profile View all posts by this user  
 
PostPosted: Thu May 10, 2012 5:12 pm 
Joined: Tue Apr 03, 2012 1:35 pm
Posts: 10
Hello,

I decided to master the simple uart first before moving to the multi-uart. Right now I'm running a simple receive then send code but I kept hitting this error :

0x0001048a in uart_rx_impl ()

or

xrun: Program received signal ET_ECALL, Application exception.
0x00010482 in uart_rx_impl ()

did anyone else had this problem?


Top
Offline Profile View all posts by this user  
 
PostPosted: Fri May 11, 2012 10:57 am 
User avatar
XMOS Employee
Joined: Fri Jan 08, 2010 12:13 am
Posts: 161
Looks like you are trying to interact with an array beyond it's bounds. ET_ECALL is a exception that is called by the code itself. XC automatically inserts array bounds checks for you - this is probably what you are running up against.


Top
Offline Profile View all posts by this user  
 
PostPosted: Sun May 13, 2012 3:57 am 
Joined: Tue Apr 03, 2012 1:35 pm
Posts: 10
I narrowed down the error to the uart modules I use the one from the xmos website. I think it's called when the buffer is full, but the documentation says it should empty itself in that case.


Top
Offline Profile View all posts by this user  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic   [ 15 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 2 guests



Search for:
Jump to: