Hi there,
I’m trying to port this IBM LMIC library to the MSP430 platform.
I have implemented the HAL but I’m struggling to get the timing correctly. The library is somehow working, I can see some “Receive uplink message” on the gateway dashboard once in a while or if I use the debug on the MSP430.
To count the ticks, I set up a timer using the 1MHz SMCLK with a divider of 8 and further divider of 2 in order to fire the interrupt every 1s. This way every tick is approximately 16us and OSTICKS_PER_SEC
is 62500. My problem is that I don’t have the micros() function so I’m quite lost on how to proceed. I read this other topic but still no solutions.
static void hal_time_init () {
TA0CCTL0 |= CCIE;
TA0EX0 = TAIDEX_1; // TAIDEX_1 is dividing the clock by 2
TA0CTL |= TASSEL__SMCLK | ID__8 | MC__CONTINUOUS; // SMCLK/8, continuous mode
__bis_SR_register(GIE);
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER1_A0_VECTOR))) Timer0_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
counter_tick+=1;
TA0CCR0 += 62500;
}
I need some help implementing the hal_ticks function. This is what I did so far:
u4_t hal_ticks () {
volatile u4_t seconds = sec2osticks(counter_tick);
return (u4_t)(sec);
}
Using the debugger I can see that after the initialisation my program keep going into the hal_io_check function forever.
static void hal_io_check() {
uint8_t GPIO_0 = (P8IN >> 0) & 0x01; // equivalent of DigitalRead(pin)
uint8_t GPIO_1 = (P7IN >> 5) & 0x01;
if (dio_states[0] != GPIO_0)
{
dio_states[0] = !dio_states[0];
if (dio_states[0])
radio_irq_handler(0);
}
if (dio_states[1] != GPIO_1)
{
dio_states[1] = !dio_states[1];
if (dio_states[1])
radio_irq_handler(1);
}
}
All the other functions are pretty much standard SPI stuff and equal to the Arduino versions so I’m sure that the problem is in how I’m counting the ticks. I’ve been working on this porting for over 2 weeks now and at this point, I’m completely out of ideas. I would be very glad if you could give me some directions!