Hi Guys, I'm new with the F28377D but very experienced with other microcontrollers.
I have a push button switch connected to PORTB0 GPIO32 and the other side to GND.
I'm trying to read the pin so when you press down on the button the port should read 1
but I can't seem to read the port. Here my code snippet:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
;PORTB EALLOW MOVL XAR7,#GPBSET ;WRITE GPBSET FIRST THEN GPBDIR MOV AL,#0 ;FOR LATCH. MOV AH,#0 MOVL *XAR7,ACC NOP MOVL XAR7,#GPBDIR ;GPIO B DIRECTION REGISTER MOV AL,#0x0 ;LOWER 16BITS - ALL OFF FOR INPUT MOV AH,#0x0 ;UPPER 16BITS - ALL OFF FOR INPUT MOVL *XAR7,ACC ;STORE IN GPBDIR REGISTER MOVL XAR7,#GPBPUD ;PORTB PULLUPS ON. 0=ON, 1=OFF MOV AL,#0x0 MOV AH,#0x0 MOVL *XAR7,ACC ;STORE IN GPADIR REGISTER EDIS ;---------------------------------------------------- MORE: LC LED_OFF MORE1: IN AL,*(GPBDAT) ;PORT B CMP AL,#0x0 B MORE,EQ LC LED_ON B MORE1,UNC |
What the above code does is sets up PORTB for input, reads PORTB.
If the push button is pressed then PORTB should = 1 and turn on a LED but
it doesn't. Can you please let me know if I am reading the port correctly or is there
other registers I have to set up first.
Thanks guys
Pete