Search code examples
cassemblytimermicroprocessorspic32

Can't access timer 4 pic32 with TMR4, T4CON etc


I've looked in the pic32ms.h file and it seems there are no definitions for timer 4. For timer 2 it has the following:

/*
 * Timer2 registers
 */
#define T2CON       PIC32_R (0x0800)
#define T2CONSET    PIC32_R (0x0808)
#define TMR2        PIC32_R (0x0810)
#define PR2         PIC32_R (0x0820)

I've tried adding lines for timer 4 with the correct addresses but it does not solve the problem. So what I want to do instead (if there's no better sollution) is to be able to call the address without using predefined values. Timer 4 has the virtual address 0x0C00 to 0x0C20. How to access these addresses and setup the timer?


Solution

  • The solution was to set the address as a volatile unsigned int pointer which could then be used to access timer 4:

    volatile unsigned int *T4CON = 0x****0C00;
    

    However I ended up only using timer 2 by changing the way I handled overflow flags so that it could be detected by different components in the code.