Forum Discussion
Altera_Forum
Honored Contributor
19 years agoTwo things to explain, I'd gather...
void* ===== The void* pointer in C means a pointer to anything (struct, simple variable, whatever...). It's the job of the function that receives the void* argument to cast it correctly. So, in the case of Count Binary, a pointer to edge_capture is passed as alt_irq_register()'s "context" argument. alt_irq_register() creates an irq "id" based structure containing handler (function pointer to ISR) and context (argument passed into ISR). It's the ISR's job to interpret the "context" data, correctly. For Count Binary, this meant to cast it to volatile int*. NOTE: context should be passed as a void* pointer. volatile ===== This tells the compiler not to optimize a variable's value away. It's commonly used for variables containing hardware register values. In the case of Count Binary, it represents the value of the edge capture register. So, to get rid of your warning you need to pass a void* pointer of ByteRec into alt_irq_register -- and then in your ISR, you need to cast this to the correct type. Though, as you already know, this is not necessary as the compiler has already done this for you.... Hope that helps! Regards, - slacker