Accessing a struct array with identical code changes output – C

Background

I am programming an AVR MCU with Microchip Studio on a custom circuit board and I do not have any debugging tools, including any form of text output, which is why I have done lots of testing in other C environments, all of which do not have this problem. My main method of testing is a motor that spins based on the output of this program. This segment of code is very different then my full code, as it has been narrowed down to isolate the problem, but the purpose is to create a filter that takes external input, puts it into an array, adds that array together, and then divides the total by the length of the array. So the inputs [180, 180, 180, 180] would be filtered to 180, and [0, 50, 100, 150] would be filtered to 75. Since 180 is hard coded, I should expect the output to be 180 and for the motor to spin at at a constant speed, however changing one of the lines of code will cause the motor to have significant changes in speed intermittently (about every second).

Problem

I have a set of 4 arrays within the struct inputs and I want to be able to access them like a 2D array. So inputs[0][0] would be the first element of inputs.zRotation and inputs[2][5] would be the 5th element of inputs.xLinear. I have narrowed down the problem to how I am accessing the members of inputs.

The program works fine with this line of code, and the motor runs normally:

inputs.zLinear[filterIndex]=180;

Changing it to this line causes the motor to start changing speed, and therefore the output of the filter has changed:

// I can even hard-code mux to 1, and the effect is the same
inputAddresses[mux][filterIndex]=180;

From this, it is apparent that inputAddresses[1] != &inputs.zLinear, and this does not make sense to me. If I change inputs.zLinear to inputAddresses[1] anywhere in the code, it stops working.

Rest of code:

#define filterLength 20

struct Inputs {
    uint8_t zRotation[filterLength];
    uint8_t zLinear[filterLength];
    uint8_t xLinear[filterLength];
    uint8_t yLinear[filterLength];
} inputs;

struct InputFilter {
    float_t zRotation;
    float_t zLinear;
    float_t xLinear;
    float_t yLinear;
} inputFilter;

uint8_t filterIndex = 0;

// This interrupt is called at 100Hz
ISR(TIMER0_COMPA_vect) {
    cli();
    
    uint8_t* inputAddresses[] = {inputs.zRotation, inputs.zLinear, inputs.xLinear, inputs.yLinear};
    
    memset(&inputFilter, 0, sizeof(inputFilter));
    
    for (uint8_t mux = 0; mux < 4; mux++) {
        // 180 would be the ADC output but here is is made a constant
        inputs.zLinear[filterIndex] = 180;
        
        for (uint8_t i = 0; i < filterLength; i++) {
            inputFilter.zLinear += inputs.zLinear[i];
        }
        inputFilter.zLinear /= filterLength;
    }
    filterIndex = (filterIndex + 1) % filterLength;

    // send output through transmitter
    sei();
}

This is very confusing, because as I had stated before I have done lots of testing of basically identical code in different environments, was changing it around accessing the struct members in all kinds of ways without issue. My leading assumption is that I have made a small syntactical error due to my limited knowledge, or that is that there is some discrepancy between compilers or the environment the code is running in.

Thanks for the help.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật