[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Paparazzi-devel] ADC Functions and Compile Sim Error

From: Brendan Chen
Subject: [Paparazzi-devel] ADC Functions and Compile Sim Error
Date: Wed, 1 Oct 2008 01:35:24 +1000

Hi all,

I'm trying to get some analog voltage into the ADC ports, I know to make 
modifications to the settings.xml I think it was to make it read the ports I'm 
hooking up, but now is using the function.
void adc_buf_channel(uint8_t adc_channel, struct adc_buf* s, uint8_t 
av_nb_sample) {
  buffers[adc_channel] = s;
  s->av_nb_sample = av_nb_sample;
>From the code above, I don't understand the whole struct idea (adc_buf*)... I 
>know the member variables and all that inside, but I don' understand what to 
>pass in for 's', and also 'av_nb_sample' - What do I pass in for that value?

Another thing I've realised, maybe because of the caml C, but basically all 
functions I saw are all of type 'void', if using type 'void' how does the 
function return a value?

For example looking at the ADC code:
void adcISR0 ( void ) {
  uint32_t tmp = AD0GDR;
  uint8_t  channel = (uint8_t)(tmp >> 24) & 0x07;
  uint16_t value = (uint16_t)(tmp >> 6) & 0x03FF;
  adc0_val[channel] = value;

  struct adc_buf* buf = buffers[channel];
  if (buf) {
    uint8_t new_head = buf->head + 1;
    if (new_head >= buf->av_nb_sample) new_head = 0;
    buf->sum -= buf->values[new_head];
    buf->values[new_head] = value;
    buf->sum += value;
    buf->head = new_head;

  VICVectAddr = 0x00000000;                 // clear this interrupt from the VIC
  ISR_EXIT();                               // recover registers and return
It's a function type 'void' with no parameters passed in I understand basically 
I would like to ask:
1. What does the ISR_ENTRY() do?
2. Whats all that code under if (buf) {...} do?
3. What variable holds the final converted data? And
4. What's the return value?

I wrote some code, and in GCS I try to build it, but it gave me a build error, 
something like: '[3] Sim Error 2' or something, what does that mean? And how 
does it occur? What should I do to fix it?


Kind Regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]