Prohibited process??

If you have a simple question and just want an answer.
Kasebe
Member++
Posts: 28
Joined: Tue Jan 07, 2014 7:49 am

Prohibited process??

Post by Kasebe »

I faced a problem when I tried a below test code on startKIT.
Debugging with xTimecomposer is OK, but execution from SPI flash written the test code is NG.
(It can not be connected with JTAG execution.)
 
[Test code]
-----
#include <xs1.h>
#include <stdio.h>
#include <platform.h>
 
in  port DIGITAL_INPUT = XS1_PORT_32A;    //PORT 32A
port out led_d1 = XS1_PORT_1A;
port out led_d2 = XS1_PORT_1D;
 
void led_thread(chanend input_data1)
{
    unsigned busy_flg;
    int delay  = 1000;
 
    printf("LED thread start!!\n");
 
    input_data1 :> busy_flg;
 
    while (1) {
        delay_milliseconds(delay);
        led_d2 <: 0;
        delay_milliseconds(delay);
        led_d2 <: 1;
    }
 
}
 
void port_inout(chanend input_data1){
 unsigned buf;
 
 printf("port_inout start!!\n");
 
 DIGITAL_INPUT :> buf;
 input_data1 <: buf;
 
 led_d1 <: 1;
 
};
 
int main(void)
{
    chan input_data;
 
    par {
 
        led_thread(input_data);
        port_inout(input_data);
    }
 
    return 0;
}
 
---
 
I could solve the problem by adding while(1) in port_inout as shown below, in short, the problem caused by the end of port_input task.
 
 
void port_inout(chanend input_data1){
 unsigned buf;
...
 led_d1 <: 1;
 
while(1); // Addition
 
};

 
I would like to know the cause.
Do anyone have something ideas?
 
Thank you.
 
 


User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

When the port is driven high without while(1) in the code, the port will be driven high and this will end with the scope of the logical core. So, you will be able to see the state of the LED changing when you add while(1) in the code.