cancel
Showing results for 
Search instead for 
Did you mean: 

How to store aRxBuffer into a variable using SPI?

Duy Khang Banh
Associate II
Posted on December 24, 2017 at 16:09

The original post was too long to process during our migration. Please click on the attachment to read the original post.
4 REPLIES 4
T J
Lead
Posted on December 25, 2017 at 21:30

Did you check if the F103 is 5V tolerant ?

do you have a serial port for debug ?

Digi key doesn't stock those parts anymore.

Duy Khang Banh
Associate II
Posted on December 26, 2017 at 13:48

I use an STM32F103C8 development board and has onboard xtal, voltage regulator and works on a pc usb output voltage, I've managed to program the 74hc595 with this board. However, programming the counterpart parallel in, serial out (HC165) is quite hard for me. Could you or anyone tell me how I can read the bit from QH from the register?

I've tried another code from a chinese source:

//

--------------------------------------------------------------------------

//

æ�¥æº�:           

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fhi.baidu.com%2Fmculove%2Fhome

//

程åº�å��称:        ç�?¨74HC165读8个按é�?®çŠ¶æ€�

//

晶振:            11.0592MHz;

//

MCUåž‹å�·:        STC89C52RC;

//

ç�?µè·¯æ�¿åž‹å�·:    EBV-MV(51实验æ�¿);

//

--------------------------------------------------------------------------   

//

--------------------------------------------------------------------------

//

硬件连接:

//

EBVn-[VCC]    ->    MVn-[--VCC--]

//

EBVn-[GND]    ->    MVn-[

//

GND

//

]

//

MVn-{EX3}-[Y0]    ->    MVn-{EX2}-[L1]

//

MVn-{EX3}-[Y1]    ->    MVn-{EX2}-[L2]

//

MVn-{EX3}-[Y2]    ->    MVn-{EX2}-[L3]

//

MVn-{EX3}-[Y3]    ->    MVn-{EX2}-[L4]

//

MVn-{EX3}-[Y4]    ->    MVn-{EX2}-[L5]

//

MVn-{EX3}-[Y5]    ->    MVn-{EX2}-[L6]

//

MVn-{EX3}-[Y6]    ->    MVn-{EX2}-[L7]

//

MVn-{EX3}-[Y7]    ->    MVn-{EX2}-[L8]

//

                     ->    MVn-{EX2}-(VCC)

//

                      ->    MVn-{EX3}-(VCC)

//

EBVn-[P10]        ->    MVn-{EX3}-[A]

//

EBVn-[P11]        ->    MVn-{EX3}-[B]

//

EBVn-[P12]        ->    MVn-{EX3}-[C]

//

EBVn-[P13]        ->    MVn-{EX3}-[G1]

//

--------------------------------------------------------------------------   

//

--------------------------------------------------------------------------

//

实验结果:

//

控制74HC138的[A,B,C,G1]端�,使[Y0,Y1..Y7]输出预期的值,LED实现了�水�显示

//

--------------------------------------------------------------------------  

//

------------------------------------------------------

//

头文件;

#include <AT89X52.H>

#define

HC165_nPL   P3_5

#define

HC165_CK    P3_6

#define

HC165_OUT    P3_7

//

------------------------------------------------------

void

delay(

void

) {     unsigned

char

i,j;    

for

(i =

250

;i >

0

;i--

)    

for

(j =

200

;j >

0

;j--

); }  unsigned

char

HC165(

void

) {     unsigned

char

i;     unsigned

char

Temp;     HC165_CK

=

1

;     HC165_nPL

=

0

;       

//

HC165读按é�?®

    HC165_nPL =

1

;       

//

æš‚å�œHC165读按é�?®

    Temp =

0

;    

if

(HC165_OUT ==

1

) Temp |=

0x01

;    

for

(i =

0

;i <

7

;i++

)     {             HC165_CK

=

0

;           HC165_CK

=

1

;           Temp

<<=

1

;        

if

(HC165_OUT ==

1

)          {             Temp

|=

0x01

;         }     }     HC165_CK

=

0

;    

return

(Temp); }   

//

------------------------------------------------------

//

程�入�;

void

main(

void

) {    

while

(

1

)     {       P1

=

HC165();       delay();     } }

However the while function 'P1 = HC165();' can't be accepted since I use GPIO with help of the STMCubeMX. Instead of that, I write ' HAL_GPIO_WritePin(GPIOB, HC165(), GPIO_PIN_SET);'. However, after uploading the program there is no output. I use GPIOB, GPIO_PIN_0 till GPIO_PIN_7. I have a HIGH signal at QA so shouldn't it be alteast 1 led turned on? 

Posted on December 26, 2017 at 18:48

The HC series parts should run fine at 3.0 or 3.3V

The F1 family has most pins as FT (5V Tolerant), likely not the ADC pins, but the functionality is broken down in the Data Sheet via the pin list.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 02, 2018 at 21:44

I use CubeMX to set all my pin declarations.

I use this code to set a pin up or down

    ETH_nReset_GPIO_Port->ODR |=  ETH_nReset_Pin;            // pin up

    ETH_nReset_GPIO_Port->ODR &= ~ETH_nReset_Pin;        // pin down

to read pins,  I read DS1..DS8 for my dipswitch;

void readDipSwitch(void){

    dipSwitch =0;

    

       if (DS8__GPIO_Port->ODR & DS8__Pin)

        dipSwitch += 0x80;

        

       if (DS7__GPIO_Port->ODR & DS7__Pin)

        dipSwitch += 0x40;

        

       if (DS6__GPIO_Port->ODR & DS6__Pin)

        dipSwitch += 0x20;

        

       if (DS5__GPIO_Port->ODR & DS5__Pin)

        dipSwitch += 0x10;

        

       if (DS4__GPIO_Port->ODR & DS4__Pin)

        dipSwitch += 0x08;

        

       if (DS3__GPIO_Port->ODR & DS3__Pin)

        dipSwitch += 0x04;

        

       if (DS2_P_GPIO_Port->ODR & DS2__Pin)

        dipSwitch += 0x02;

        

       if (DS1__GPIO_Port->ODR & DS1__Pin)

        dipSwitch += 0x01;

}