Reputation: 11
So I've got the following example code that prints the temperature of a connected temp sensor. But this line I don't understand
NVIC->IP[20] = 0x60; //Set interupt priority to 3
How does a hex value of 0x60 corresponds to a priority of 3? And where did they got this from.
FULL CODE BELOW:
#include <stdio.h>
#include <stdint.h>
uint8_t data;
#include "msp.h"
#include "msp432.h"
#include "math.h"
void pin_setup(){
P1->SEL0 |= 0xC0;
P1->SEL1 &= 0xC0;
}
void twi_master_setup(){
EUSCI_B0->CTLW0 = 0x0001;
EUSCI_B0->CTLW0 = 0x0F51;
EUSCI_B0->CTLW1 = 0x0008; // Set auto stop on byte counter
EUSCI_B0->TBCNT = 0x0001; // Set byte counter to 1
EUSCI_B0->BRW = 0x0040; // Set clock prescaler to 64
EUSCI_B0->CTLW0 &= ~0x0001; // Release software reset
EUSCI_B0->IE |= 0x0003;
NVIC->IP[20] = 0x60; //Set interupt priority to 3
NVIC->ISER[0] |= 0x00100000; // Enable interupt
}
void i2cB0receive() {
EUSCI_B0->I2CSA = 0x48;
EUSCI_B0->CTLW0 &= ~0x0010;//Switch to receiver mode
EUSCI_B0->CTLW0 |= 0x0002;//Issue start condition;
}
void EUSCIB0_IRQHandler() {
uint16_t temp;
temp = EUSCI_B0->IFG; // copy interrupt flags to temp variable
if(temp & 0x0001){
EUSCI_B0->CTLW0 |= 0x0004;//EUSCI_B_CTLW0_SWRST;
EUSCI_B0->IFG &= ~0x0001;
data = EUSCI_B0->RXBUF;
}
}
int main(void)
{
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;
pin_setup();
twi_master_setup();
while(1){
i2cB0receive();
int8_t temp = (int8_t)data;
printf("%d\n",temp);
}
}
I've found this table in the datasheet but 0x60 to binary = 01100000 corresponds to the 6th and the 7th bit. This doesn't come close to a priority of 3.
Maybe I'm using the wrong table?
Upvotes: 1
Views: 26