This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Code stops working after enabling timer

Hello, 

I've been starting to get into level 0.1 programming after being able to loosely control an LED with GPIOTE and a timer interrupt using examples and API references (copying code parts from the example)

And now I'm just trying to read data(With the simplest method of ACTUAL Serial interface using a Clock and a Data pin)

and for some reason after enabling the timer the while loop doesn't seems to want to exit despite the sanctification of the condition which as a beginner realy makes the vision over this platform distorted and difficult

Here's the code: 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "nrf_drv_gpiote.h" //GPIOTE driver
#include "nrf_gpio.h"
#include "pca10040.h" //Pins mapping to meaningful macroas for the nRF52840-DK (aka pca10056)
#include "nrf_drv_timer.h"
#define CLK_PIN 24
#define DT_PIN 25
#define GAIN 1
int Data = 0;
int BitPos = 27;
void timer0_event_handler(nrf_timer_event_t event_type, void *p_context){
Data << 1;
nrf_gpio_pin_set(CLK_PIN);
Data |= nrf_gpio_pin_read(DT_PIN);
nrf_gpio_pin_clear(CLK_PIN);
BitPos++;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Also pretty sure what ever I tried there to read that 24 bit data from that HX711 is not the proper way(using timer and all that salad there) but can't get to my mind how to do this otherwise sins the main clock frequency is realy too high for purely pulsing the clock signal the HX711 needs and in arduino you'd just write the shiftIn() function but here I have no idea of even how to look for it sins example API are rare and not that clear, and it'd take ages to scan the nordic info center documentation for that, so If there is a simpler method to read Serial data I'd be highly appreciated.

thanks for helping!