Hello everybody.
I need to have an Impulse C program that can send 2 streams from software to hardware.
when I do this using 2 producer functions it works well (I tested it on the fcb bus of ppc405).
void Producer1(co_stream a) {
co_uint16 a_value;
a_value = 31;
co_uint16 *a_pointer;
co_stream_open(a,O_WRONLY,co_uint16_TYPE);
a_pointer = &a_value;
printf("Producer1 passed a=%d\n",a_value);
co_stream_write(a,a_pointer,sizeof(co_uint16));
co_stream_close(a);
}
and, producer2 is the same as producer1.
but when I do this using one producer function it sends the value of the stream that is first declared in "co_uint16 a_value,b_value;" to both streams!!! (although printf function prints the right values)
void Producer(co_stream a,co_stream b ) {
co_uint16 a_value,b_value;
a_value = 2;
b_value = 3;
co_uint16 *a_pointer,*b_pointer;
co_stream_open(a,O_WRONLY,co_uint16_TYPE);
co_stream_open(b,O_WRONLY,co_uint16_TYPE);
a_pointer = &a_value;
b_pointer = &b_value;
printf("Producer passed a=%d & b=%d \n",a_value,b_value);
co_stream_write(a,a_pointer,sizeof(co_uint16));
co_stream_write(b,b_pointer,sizeof(co_uint16));
co_stream_close(a);
co_stream_close(b );
}
can anybody tell me why this happens?
thanks in advance.
streams
Started by fatemeh, Apr 22 2008 07:27 AM
10 replies to this topic
#1
Posted 22 April 2008 - 07:27 AM
#2
Posted 22 April 2008 - 10:15 AM
QUOTE (fatemeh @ Apr 22 2008, 09:27 AM) <{POST_SNAPBACK}>
Hello everybody.
I need to have an Impulse C program that can send 2 streams from software to hardware.
when I do this using 2 producer functions it works well (I tested it on the fcb bus of ppc405).
...
and, producer2 is the same as producer1.
but when I do this using one producer function it sends the value of the stream that is first declared in "co_uint16 a_value,b_value;" to both streams!!! (although printf function prints the right values)
...
can anybody tell me why this happens?
thanks in advance.
I need to have an Impulse C program that can send 2 streams from software to hardware.
when I do this using 2 producer functions it works well (I tested it on the fcb bus of ppc405).
...
and, producer2 is the same as producer1.
but when I do this using one producer function it sends the value of the stream that is first declared in "co_uint16 a_value,b_value;" to both streams!!! (although printf function prints the right values)
...
can anybody tell me why this happens?
thanks in advance.
Hi,
What does the code in your co_initialize() (co_init.c) look like for the single producer case? And how are you calling Producer()? If stream 'a' and 'b' are somehow the same pointer you would write to the same stream twice.
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#3
Posted 23 April 2008 - 05:26 AM
QUOTE (etrexel @ Apr 22 2008, 09:45 PM) <{POST_SNAPBACK}>
Hi,
What does the code in your co_initialize() (co_init.c) look like for the single producer case? And how are you calling Producer()? If stream 'a' and 'b' are somehow the same pointer you would write to the same stream twice.
Ed
What does the code in your co_initialize() (co_init.c) look like for the single producer case? And how are you calling Producer()? If stream 'a' and 'b' are somehow the same pointer you would write to the same stream twice.
Ed
co_architecture co_initialize(void *arg)
{
co_stream stream1;
co_stream stream2;
co_stream stream3;
co_stream stream4;
co_stream stream5;
unsigned int membase;
stream1=co_stream_create("stream1",UINT_TYPE(16),2);
stream2=co_stream_create("stream2",UINT_TYPE(16),2);
stream3=co_stream_create("stream3",UINT_TYPE(16),2);
stream4=co_stream_create("stream4",UINT_TYPE(16),2);
stream5=co_stream_create("stream5",UINT_TYPE(16),2);
co_process_create("Producer",(co_function)Producer,
2,
stream1,
stream2);
co_process_create("Consumer",(co_function)Consumer,
3,
stream3,
stream4,
stream5);
/* Architecture Initialization */
mtmsr(XREG_MSR_APU_AVAILABLE);
co_stream_attach(stream1,0,HW_INPUT);
co_stream_attach(stream2,4,HW_INPUT);
co_stream_attach(stream3,8,HW_OUTPUT);
co_stream_attach(stream4,12,HW_OUTPUT);
co_stream_attach(stream5,16,HW_OUTPUT);
return(NULL);
}
I do not call producer explicitly. my main program:
int main (int argc, char *argv[]) {
int param = 0;
co_architecture my_arch;
printf("-- Entering main() --\r\n");
my_arch = co_initialize(param);
co_execute(my_arch);
printf("-- Exiting main() --\r\n");
return(0);
}
thanks.
#4
Posted 23 April 2008 - 01:54 PM
QUOTE (fatemeh @ Apr 23 2008, 07:26 AM) <{POST_SNAPBACK}>
co_architecture co_initialize(void *arg)
{
...
{
...
Hi,
That does look correct, there's always a chance that the driver or HDL is incorrect. What version are you running? And would it be possible to send in your project to support@impulsec.com for inspection?
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#5
Posted 27 April 2008 - 04:41 AM
QUOTE (etrexel @ Apr 24 2008, 01:24 AM) <{POST_SNAPBACK}>
Hi,
That does look correct, there's always a chance that the driver or HDL is incorrect. What version are you running? And would it be possible to send in your project to support@impulsec.com for inspection?
Ed
That does look correct, there's always a chance that the driver or HDL is incorrect. What version are you running? And would it be possible to send in your project to support@impulsec.com for inspection?
Ed
Hi,
I am using CoDeveloperUniversal_3.10.b.9.
I sent my project to support@impulsec.com.
thanks.
#6
Posted 27 April 2008 - 09:42 AM
QUOTE (fatemeh @ Apr 27 2008, 06:41 AM) <{POST_SNAPBACK}>
Hi,
I am using CoDeveloperUniversal_3.10.b.9.
I sent my project to support@impulsec.com.
thanks.
I am using CoDeveloperUniversal_3.10.b.9.
I sent my project to support@impulsec.com.
thanks.
Hi,
In the files you had sent, everything looks correct - it looks a little different than what you had orginally posted, have you run the project on hardware and still see the same error?
I assume you are exporting to EDK - can you describe the steps you do each time?
Please be sure to that each time you export hardware and software that you do a "Generate Libraries and BSP" in EDK to capture the changes in the exported driver code (apu_if.h is all that should change, but it is used both by the application and the driver).
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#7
Posted 30 April 2008 - 05:46 AM
QUOTE (etrexel @ Apr 27 2008, 09:12 PM) <{POST_SNAPBACK}>
Hi,
In the files you had sent, everything looks correct - it looks a little different than what you had orginally posted, have you run the project on hardware and still see the same error?
I assume you are exporting to EDK - can you describe the steps you do each time?
Please be sure to that each time you export hardware and software that you do a "Generate Libraries and BSP" in EDK to capture the changes in the exported driver code (apu_if.h is all that should change, but it is used both by the application and the driver).
Ed
In the files you had sent, everything looks correct - it looks a little different than what you had orginally posted, have you run the project on hardware and still see the same error?
I assume you are exporting to EDK - can you describe the steps you do each time?
Please be sure to that each time you export hardware and software that you do a "Generate Libraries and BSP" in EDK to capture the changes in the exported driver code (apu_if.h is all that should change, but it is used both by the application and the driver).
Ed
Hi.
yes, I tested it on hardware.
It is supposed to give the sum, but it gives 2*a, if b is defined first in "co_uint16 b_value,a_value;" it gives 2*b.
The answer is independent of the order in which arguments are defined."Producer(co_stream b,co_stream a)"
I enter the address of the edk project in hardware and software export directory.
Every time I export the pcore to EDK, I choose clean software and clean hardware to be sure that the new pcore will be used.
#8
Posted 30 April 2008 - 08:13 AM
QUOTE (fatemeh @ Apr 30 2008, 07:46 AM) <{POST_SNAPBACK}>
Hi.
yes, I tested it on hardware.
It is supposed to give the sum, but it gives 2*a, if b is defined first in "co_uint16 b_value,a_value;" it gives 2*b.
The answer is independent of the order in which arguments are defined."Producer(co_stream b,co_stream a)"
I enter the address of the edk project in hardware and software export directory.
Every time I export the pcore to EDK, I choose clean software and clean hardware to be sure that the new pcore will be used.
yes, I tested it on hardware.
It is supposed to give the sum, but it gives 2*a, if b is defined first in "co_uint16 b_value,a_value;" it gives 2*b.
The answer is independent of the order in which arguments are defined."Producer(co_stream b,co_stream a)"
I enter the address of the edk project in hardware and software export directory.
Every time I export the pcore to EDK, I choose clean software and clean hardware to be sure that the new pcore will be used.
Hi,
So let me get this straight, if you have the line:
co_uint16 b_value,a_value;
The result will be 2*b.
And if you have the line:
co_uint16 a_value,b_value;
The result will be 2*a.
Is that correct? If so, try defining them as:
co_uint32 b_value,a_value;
and leaving the sizeof(co_uint16) the same for co_strema_write().
and see if that makes a difference.
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#9
Posted 17 June 2008 - 03:34 AM
Hi
I'm really sorry for the long delay, I was busy with my final exams.
yes, it's exactly what happens.
I tested it, but it did not make any difference.
I'm really sorry for the long delay, I was busy with my final exams.
QUOTE (etrexel @ Apr 30 2008, 07:43 PM) <{POST_SNAPBACK}>
So let me get this straight, if you have the line:
co_uint16 b_value,a_value;
The result will be 2*b.
And if you have the line:
co_uint16 a_value,b_value;
The result will be 2*a.
co_uint16 b_value,a_value;
The result will be 2*b.
And if you have the line:
co_uint16 a_value,b_value;
The result will be 2*a.
yes, it's exactly what happens.
QUOTE (etrexel @ Apr 30 2008, 07:43 PM) <{POST_SNAPBACK}>
try defining them as:
co_uint32 b_value,a_value;
and leaving the sizeof(co_uint16) the same for co_strema_write().
co_uint32 b_value,a_value;
and leaving the sizeof(co_uint16) the same for co_strema_write().
I tested it, but it did not make any difference.
#10
Posted 19 June 2008 - 07:36 PM
QUOTE (fatemeh @ Jun 17 2008, 05:34 AM) <{POST_SNAPBACK}>
Hi
I'm really sorry for the long delay, I was busy with my final exams.
yes, it's exactly what happens.
I tested it, but it did not make any difference.
I'm really sorry for the long delay, I was busy with my final exams.
yes, it's exactly what happens.
I tested it, but it did not make any difference.
Hi,
Huh. How about trying to use globals(locals don't appear to get aligned) aligned as:
co_uint32 b_value,a_value __attribute__ ((aligned (4)));
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#11
Posted 29 June 2008 - 04:51 AM
QUOTE (etrexel @ Jun 20 2008, 07:06 AM) <{POST_SNAPBACK}>
Hi,
Huh. How about trying to use globals(locals don't appear to get aligned) aligned as:
co_uint32 b_value,a_value __attribute__ ((aligned (4)));
Ed
Huh. How about trying to use globals(locals don't appear to get aligned) aligned as:
co_uint32 b_value,a_value __attribute__ ((aligned (4)));
Ed
Thank you very much.
It now works
I used: co_uint16 b_value,a_value __attribute__ ((aligned (16)));
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












