-------- Initialisierung der Pins, hier nur Temporaer gezeigt fuer mikrocontroller.net PORT->Group[0].PINCFG[PIN_PA05].reg = PORT_PINCFG_INEN | PORT_PINCFG_PULLEN;//DT pin from Scale PORT->Group[0].OUTSET.reg |= (1 << PIN_PA05); //Enable Pullup PORT->Group[0].DIRSET.reg |= (1 << PIN_PA24); //SCK pin from Scale (set as Output) PORT->Group[0].OUTCLR.bit.OUTCLR = PORT_PA24; //SCK LOW --------- if(request_scale) { if (!(PORT->Group[0].IN.reg & PORT_PA05)) //Wait DP is low { //pin is low and ready to begin raw_scale_val = 0; //Reset previous result asm volatile ("nop"); //T1 DOUT falling edge to PD_SCK rising edge 0,1us for(uint32_t x = 0; x < 24; x++) { PORT->Group[0].OUTSET.reg |= (1 << PIN_PA24); //Set CLK Pin and wait for DATA on DP asm volatile ("nop"); //T2 PD_SCK rising edge to DOUT data ready 0,1us PORT->Group[0].OUTSET.reg &=~ PORT_PA24; //SCK LOW if (PORT->Group[0].IN.reg & PORT_PA05) { raw_scale_val += 1; uart_send('1'); } else uart_send('0'); raw_scale_val = raw_scale_val << 1; //Shift to left. DP starts with MSB asm volatile ("nop"); //T4 PD_SCK low time 0,2us } PORT->Group[0].OUTSET.reg |= (1 << PIN_PA24); //Set CLK 25' to signal end | More ticks have another functions, see data sheet raw_scale_val = raw_scale_val >> 1; //Shift to right position asm volatile ("nop"); //T3 PD_SCK high time 0,2us PORT->Group[0].OUTCLR.bit.OUTCLR = PORT_PA24; //SCK LOW request_scale = 0; //End request scale after successful data receive uart_string(" Binary\r\n"); uart_string(calca32(raw_scale_val)); //Output result DEC to String uart_string(" Scale RAW value\r\n"); } }