Ive been struggling trying to get my global variable ‘numOverflows’ to be accesable in my ISR. It’s only purpose is to keep track of time. Right now I’m just trying to get it to display in the main(). When i printf() in main, it displays a 0, which makes no sense considering I know that the ISR is being called (thats what the PORTB ^= is for.). I was expecting it to count up as the ISR is called and then overflow. I’m sure this is a simple error but I have already spent hours researching and couldn’t find help, so I do appreciate any.
typedef union
{
struct
{
uint8_t LED_0 : 1; // LED 0 state
uint8_t LED_1 : 1; // LED 1 state
uint8_t LED_2 : 1; // LED 2 state, also the game over state
uint8_t Strike : 1; // State for tweezers striking the board
uint8_t Counter_0 : 1; // Bits which count overflows (keep track of game time)
uint8_t Counter_1 : 1; // ^
uint8_t Counter_2 : 1; // ^^
uint8_t Counter_3 : 1; // ^^^
}bits;
unsigned char full;
} data_field;
int main(void)
{
// Create File Pointers for in and out
FILE uart_output = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);
FILE uart_input = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ);
// Initialize the UART Driver
uart_init();
// Hijack STDIN/STDOUT and send then to the UART Driver
stdout = &uart_output;
stdin = &uart_input;
// Char used for getting info from UART
char input;
You missed the part where Delta_G asked you to use code tags.
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.