|
--On Wednesday, June 25, 2003 6:32 AM -0700 Mike Rosing <> wrote: > Hardware wise, yes there is. Make the 12 bits go into > the most significant bit positions. So when you read > the raw data, it's already sign correct. If you want, > mask off the last 4 bits (if you read 16) or 20 if you > read 32. Then it takes zero time to fix the problem, > because the problem doesn't exist! When you improve your product later and buy a wider ADC, continue to connect the sign bit of the ADC to the sign bit of the SHARC's data bus. Think of an ADC reading as a fraction between -1 and 1, with better ADC's having more low order bits in the fraction. Then you won't have to change your software as you change the quality of the ADC. |
I2S sign extension
Started by ●June 24, 2003
Reply by ●June 28, 20032003-06-28
Reply by ●June 30, 20032003-06-30
|
Hi Thanks Friedrich. I thought that the ADC provides data at PCM format and my thought never check the other available formats, like one what you mentioned (fixed point format). I also thinks that the SHARC short word addressing is limited to its internal memory space. regards ajith --- "Burgwedel, Friedrich" <> wrote: > Hi Ajith, > > I don't think that there is something like short > word memory adress space > for external memory -- I'm not 100% sure about this > without looking into the > manuals, but if I'm right your fifo will allways be > accessed as 32 bit word. > > > In order to get the original data back, either we > have to divide the > > data by 2^20 (pls note also that division will > take more cycles - the > > other solution is shift right back.) > > 'real programmers never divide by a power of two'. > > > or use "FLOAT Rx by Ry" instruction in assembly > > If you do your signal processing in floating point > format anyway this would > be the way to go. (use inline assembler if > neccessary). > > > Is it no need of shifting right back after the > shift left operation > > in the above mentioned problem? Then the data > become a scaled one, > > no? Is there any case where this kind of situation > arises? > > You may want to use the ADC value in fractional > fixed point format - that > is, the nominal range of your samples is assumed to > be [-1,1[ represented in > a way that all bit are just the fractions 2^(-1), > 2^(-2),...2^(-32). This is > a very conveniant representation for fixed point > signal data (sometimes you > can achive lower noise by using fixed point > filtering) and is supported by > the core. > > I would try to avoid the 'full hardware solution' if > your fifo output cannot > drive multiple data bus lines at the specified speed > since the data bus > driver would involve addition cost that has to be > multiplied with your > production lot size... > > So long > Friedrich > > -----Ursprgliche Nachricht----- > Von: ajith_pc [mailto:] > Gesendet: Freitag, 27. Juni 2003 07:35 > An: > Betreff: [adsp] Re: sign extension in C > Hi all, > i have some about the connecting the 12 bits of the > FIFO to > the higher bit position of the data bus. If it is > short word data > (16bit), it is same as shifting 4 bit position, i.e > scaled by 2^4. So > the output is the scaled version of the input. This > is same for the > 32bit data, here the scaling factor is 2^20. Pls > note that in ADSP > Sharc compiler, the short integer also represented > by 32 bit. So the > effective shifting is 20 bit in that case. In order > to get the > original data back, either we have to divide the > data by 2^20 (pls > note also that division will take more cycles - the > other solution is > shift right back.) or use "FLOAT Rx by Ry" > instruction in assembly ( > i am not sure the corresponding instruction in C). I > think in general > it is better to use assembly for bit wise operation > rather than go > for C. in line assembly is also a solution. The > other solution is use > shift left and then right back with out change any > hardware, as Jens > showed. Jens, I am not understand why you adds this > lines "In many > application you can leave the second part away." > after the shifting > operation > "signed short val = MyAdcValue; > val<<=4; // shift so that sign is in sign bit > val>>=4; // shift in old place, there you are > In many application you can leave the second part > away. > " > Is it no need of shifting right back after the shift > left operation > in the above mentioned problem? Then the data > become a scaled one, > no? Is there any case where this kind of situation > arises? > For the full hardware solution I think it is better > option is what > Friedrich mentioned. I am quoting his lines "you can > shift your fifo > connection to lower bits as you like; you just have > to connect all > free higher bits of the data bus to the MSB of your > fifo output.-- > Check your fifo output driver capability..." > rgds > ajith > --- In , "Jens Michaelsen" > <jens.michaelsen@w...> > wrote: > > Please be more precise in your question! > > > > What is your destination variable length 16 or 32 > bit? > > > > Here a short example how to sign extend > > a 12 bit value in a 16bit register or variable. > > > > signed short val = MyAdcValue; > > val<<=4; // shift so that sign is in sign bit > > val>>=4; // shift in old place, there you are > > > > In many application you can leave the second part > away. > > > > Be aware the not all ADC send signed results. > > In such case sub the MSB first. > > > > Jens > > _____________________________________ > Note: If you do a simple "reply" with your email > client, only the author of > this message will receive your answer. You need to > do a "reply all" if you > want your answer to be distributed to the entire > group. > > _____________________________________ > About this discussion group: > > To Join: Send an email to > To Post: Send an email to > > To Leave: Send an email to > Archives: http://groups.yahoo.com/group/adsp > > Other Groups: http://www.dsprelated.com/groups.php3 > ">http://docs.yahoo.com/info/terms/ > __________________________________ |
|
|
Reply by ●June 30, 20032003-06-30
|
I've found a work around for the moment. In my interrupt routine when
a buffer is full I generate a pseudo interrupt using the "signal" call and one of the user defined interrupts. This permits my interrupt to continue so I don't miss any interrupts but removing the overhead of polling. Using the signal call has reduced my overhead considerably. Too bad there is not a more convenient way to use the DAG. At 10:53 PM 6/29/2003 -0700, Ajith Kumar P C wrote: >Hi >Thanks Friedrich. I thought that the ADC provides >data at PCM format and my thought never check the >other available formats, like one what you mentioned >(fixed point format). I also thinks that the SHARC >short word addressing is limited to its internal >memory space. >regards >ajith > >--- "Burgwedel, Friedrich" <> >wrote: > > Hi Ajith, > > > > I don't think that there is something like short > > word memory adress space > > for external memory -- I'm not 100% sure about this > > without looking into the > > manuals, but if I'm right your fifo will allways be > > accessed as 32 bit word. > > > > > In order to get the original data back, either we > > have to divide the > > > data by 2^20 (pls note also that division will > > take more cycles - the > > > other solution is shift right back.) > > > > 'real programmers never divide by a power of two'. > > > > > or use "FLOAT Rx by Ry" instruction in assembly > > > > If you do your signal processing in floating point > > format anyway this would > > be the way to go. (use inline assembler if > > neccessary). > > > > > Is it no need of shifting right back after the > > shift left operation > > > in the above mentioned problem? Then the data > > become a scaled one, > > > no? Is there any case where this kind of situation > > arises? > > > > You may want to use the ADC value in fractional > > fixed point format - that > > is, the nominal range of your samples is assumed to > > be [-1,1[ represented in > > a way that all bit are just the fractions 2^(-1), > > 2^(-2),...2^(-32). This is > > a very conveniant representation for fixed point > > signal data (sometimes you > > can achive lower noise by using fixed point > > filtering) and is supported by > > the core. > > > > I would try to avoid the 'full hardware solution' if > > your fifo output cannot > > drive multiple data bus lines at the specified speed > > since the data bus > > driver would involve addition cost that has to be > > multiplied with your > > production lot size... > > > > So long > > Friedrich > > > > -----Ursprgliche Nachricht----- > > Von: ajith_pc [mailto:] > > Gesendet: Freitag, 27. Juni 2003 07:35 > > An: > > Betreff: [adsp] Re: sign extension in C > > > > > > Hi all, > > i have some about the connecting the 12 bits of the > > FIFO to > > the higher bit position of the data bus. If it is > > short word data > > (16bit), it is same as shifting 4 bit position, i.e > > scaled by 2^4. So > > the output is the scaled version of the input. This > > is same for the > > 32bit data, here the scaling factor is 2^20. Pls > > note that in ADSP > > Sharc compiler, the short integer also represented > > by 32 bit. So the > > effective shifting is 20 bit in that case. In order > > to get the > > original data back, either we have to divide the > > data by 2^20 (pls > > note also that division will take more cycles - the > > other solution is > > shift right back.) or use "FLOAT Rx by Ry" > > instruction in assembly ( > > i am not sure the corresponding instruction in C). I > > think in general > > it is better to use assembly for bit wise operation > > rather than go > > for C. in line assembly is also a solution. The > > other solution is use > > shift left and then right back with out change any > > hardware, as Jens > > showed. Jens, I am not understand why you adds this > > lines "In many > > application you can leave the second part away." > > after the shifting > > operation > > "signed short val = MyAdcValue; > > val<<=4; // shift so that sign is in sign bit > > val>>=4; // shift in old place, there you are > > In many application you can leave the second part > > away. > > " > > Is it no need of shifting right back after the shift > > left operation > > in the above mentioned problem? Then the data > > become a scaled one, > > no? Is there any case where this kind of situation > > arises? > > For the full hardware solution I think it is better > > option is what > > Friedrich mentioned. I am quoting his lines "you can > > shift your fifo > > connection to lower bits as you like; you just have > > to connect all > > free higher bits of the data bus to the MSB of your > > fifo output.-- > > Check your fifo output driver capability..." > > rgds > > ajith > > > > > > > > > > > > > > > > > > --- In , "Jens Michaelsen" > > <jens.michaelsen@w...> > > wrote: > > > Please be more precise in your question! > > > > > > What is your destination variable length 16 or 32 > > bit? > > > > > > Here a short example how to sign extend > > > a 12 bit value in a 16bit register or variable. > > > > > > signed short val = MyAdcValue; > > > val<<=4; // shift so that sign is in sign bit > > > val>>=4; // shift in old place, there you are > > > > > > In many application you can leave the second part > > away. > > > > > > Be aware the not all ADC send signed results. > > > In such case sub the MSB first. > > > > > > Jens > > > > > > > > _____________________________________ > > Note: If you do a simple "reply" with your email > > client, only the author of > > this message will receive your answer. You need to > > do a "reply all" if you > > want your answer to be distributed to the entire > > group. > > > > _____________________________________ > > About this discussion group: > > > > To Join: Send an email to > > > > > > To Post: Send an email to > > > > To Leave: Send an email to > > > > > > Archives: http://groups.yahoo.com/group/adsp > > > > Other Groups: http://www.dsprelated.com/groups.php3 > > > > > > ">http://docs.yahoo.com/info/terms/ > >__________________________________ >_____________________________________ >Note: If you do a simple "reply" with your email client, only the author >of this message will receive your answer. You need to do a "reply all" if >you want your answer to be distributed to the entire group. > >_____________________________________ >About this discussion group: > >To Join: Send an email to > >To Post: Send an email to > >To Leave: Send an email to > >Archives: http://groups.yahoo.com/group/adsp > >Other Groups: http://www.dsprelated.com/groups.php3 >">http://docs.yahoo.com/info/terms/ |
|
|
Reply by ●July 6, 20032003-07-06
|
--On Monday, June 30, 2003 7:50 AM -0600 Steve Holle <> wrote: > I've found a work around for the moment. In my interrupt routine when a > buffer is full I generate a pseudo interrupt using the "signal" call and > one of the user defined interrupts. This permits my interrupt to > continue so I don't miss any interrupts but removing the overhead of > polling. While a good solution, look out for the chip errata about setting bits in IRPTL and the potential for losing an interrupt. Be sure to put any code that affects IRPTL (like signal()) in internal memory. |






