- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody
my problem is using DFB assembler to multiply two signed number.
my project is attached
when I put two positive number in bus1 and dataramB the multiplication result is correct, but when I put negative number(for example cff001) the output is incorrect
in this project after run simulation in simulator in cycle10 the output is incorrect
furthermore when I input the negative numer in simulatot this number is shown as 32 bit number for example for cff001 it shows ffcff001
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like result sign extended into 32 bits.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
all of the 32 bits are incorrect when signed multiply is execute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But you are aware of the fact that the result represents a number between -1 and 1 ?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A 24-bit number has got six (6) hex digits and not only five (5) as your input to the filter is. The sign expansion will treat all your numbers as positive.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, the 24'th bit is the sign bit
my first input is(0x23456) and my firs coefficient (in the end of my assembly code) is 0xcff001(negative nymber) and defined by dw 0xcff001 but the Mac output in the 10'th cycle is FFFF2C19 (this is incorrect result)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes,the 24'th bit is the sign bit
my first input in bus1 is 0x23456(positive number) and my coefficient is 0xcff001(negative number) and defined in the end of my assembly code
but the mac output in the 10'th cycle is FFFF2C19 and that is incorrect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since the digital filter in the PSoC is widely used and working without complains you should concentrate on interpreting the results you have got. In the datasheet on pg. 22 is described that the integer values have to be interpreted as values between -0.99999 and +0.99999 which in turn implies a scaling when two of the numbers are multiplied. Adding or subtracting works without scaling since the denominator is the same for both summands.
I calculated the numbers you provided using windows calculator (set to programmer's mode) and I got as result 0xffff2c1a.
Do not forget that you have to observe
1. expanding to qwords including the sign
2. scaling the result by dividing by 0x7fffff
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't understand the result of multiply is here and after deviding the result is 394c5
how you can get thjat answer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
0x23456 * 0xFFFFFFFFFFCFF001 = FFFFFF960C9CD456
FFFFFF960C9CD456 / 0x7FFFFF = FFFFFFFFFFFF2C1A
OK?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes,it's Ok
but my number is cff001 not 0xFFFFFFFFFFCFF001
I want to calculate the result of 0x23456*0xcff001
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
0xcff001 has to be sign extended to get a qword since bit 23 is on it is a negative number. and 0xfffffcff001 is quite the same.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob,
Your answer was very helpfull for me
I have one question:
when I want to multiply(in decima) -5*-5=25 what should i do?
I know that the DFB assmes a point after MSB, then I shoul put 0x805000 in Bus1 and 0x805000 in coefficient memory in my assembly code,
result of multiply is 3FB019000000(0x19=25,but what is teh 3FB in the first?) .
after dividing 3FB019000000 by 7FFFFF the result is 7F6032,this is the same as the simulator result but I want to obtain the real result of multiplicatin
I want to implement the algorithm with many filters,These filters have fixed coefficient for example one of this filter's cosfficient is -0.1294 0.2241 0.8365 0.4830
how I can get this coefficent anf achive the result of multiplication
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You get the coefficients by multiplying your number 0.1294 by 0x7FFFFF which is
0.1294 * 8388607 = 1085486 (rounded) = 0x10902E
Negation delivers
- 0x10902E = 0xEF6FD2
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much Bob,
your help was great for me.I multiplied any coefficient by 7FFFFF and my output is correct for lowpass filtering.
my algorithm is here. I have been sucessed in lowpass filtering in any stage but I can't get the high pass filter the same as the matlab's result. the g is lowpass and the h is high pass and I have any filter coefficient from matlab toolbox
I just get the filter coefficient and then MACC with any input.
for lowpass filterin I get the correct result but for highpass I didn't.
for example my highpass filter's coefficient is -0.4830 0.8365 -0.2241 -0.1294
I don't know what is incorrect in my code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, the coef is correct but the ouput of multipling in matlab in 2'th level(for highpass filtering) is -3.41*(10^-13) and this answer is very small and i can't see it in macc output
I see 0 in output of mac
what can I do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The result of the multiplication is zero. When you multiply your given value with your well-known 8388607 you see that the result is less than 1. That is integer zero. the precision of your matlab seems to be better than that of the filter.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
there isn't any way ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your way is correct, what does in your case a difference in the result of 10^-5 make?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know
for lowpass filtering I trace the output by muktiply accumulate input by any coeffs
for example 2010*(sum of lowpass coeffs) and this is correct
but for highpass filtering result of multiply and the add didn't get me the correct result
2010*(sum of highpass coeffs) isn't equal with matlab output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the overall difference between what you get and what you should have?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Bob,
my problem is resolved,my assembly code works good.
now I want to write the main.c code for implemneting my topdesign scheme
I used from 2 DMA in my project but when I put the DMA wizard code generated in main.c it couln't work
I attached my project
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have not put any code into your project, so nothing I can comment on. There is an app note dealing with DMA, did you have a look at? www.cypress.com/
You have connected the (-) input of the ADC to the (+) input of your PGA, which will that signal leave floating.
Some of your componentst are outdated, I would suggest you to update Crteator to latest version or even upgrade to the co-existent version 3.1.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are DMA example projects you can draw from, just open them
in your project, then close that workspace after you are done pulling code
from them. Start page of Creator, find "Find example project" link.
http://www.cypress.com/?rID=37793 AN52705 Getting Started with DMA
http://www.cypress.com/?rID=82680 AN84810 PSoC® 3 and PSoC 5LP Advanced DMA Topics
http://www.cypress.com/?rID=44335 AN61102 PSoC® 3 and PSoC 5LP - ADC Data Buffering Using DMA
http://video.cypress.com/video-library/search/dma/ Videos on DMA
https://www.youtube.com/results?search_query=dma+psoc Videos on DMA (some overlap)
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All API-names are precieded by the component's name, so best is to change the names by removing the trailling "_1" which have been inserted automatically.
The declartion for DMA_Config is missing and must appear before the first reference to it.
main() is of type int (as conforming to standard C-language)
When that's corrected we will help you further...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Be careful when removing the _n suffix on a name, more specifically
check your name is not a reserved word for Compiler when you do
as not all named objects Compiler has will error flag you on a compile.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to transfer the output of DFB to host
I tried oll of creator example methods but I couldn't get success
I installed suit usb but I think it can't show the value of the endpoint
I'm very confused
please get some help
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please post your actual project. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BTW: Which development kit do you use? CY8CKit-001?? CY8CKit-050???
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content