MCU Hangs on register write

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
zmEE22
Posts: 4
Joined: 04 Aug 2022 16:54

MCU Hangs on register write

#1 Post by zmEE22 » 04 Aug 2022 17:03

Hi,

I am trying to program the MK64FX512VLQ12 microcontroller.

When I program the UART0_C1 register directly, I find that the microcontroller immediately begins to hang.

I tried to attach my mode but the forum wouldn't let me.

I dropped it below.

Thank you for the help!


program Code

' Declarations section
Dim databuf as byte[50] 'input data buffer
Dim dataStr as string[50]


main:
' Main program
' Setup Heartbeat LEDs
''''''''''''''''
'PTE9 -> D9
'PTE8 -> D10
'PTE7 -> D11
GPIO_Digital_Output(@PTE_PDOR, _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7)
GPIOE_PCOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7
Delay_ms(100)
GPIOE_PSOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7
Delay_ms(100)
GPIOE_PCOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7
Delay_ms(10)
''''''''''''''''

' Setup UART for FTDI
'UART0_TX on PTD7 ALT3
'UART0_RX on PTD6 ALT3
'UART0_CTSB on PTD5
'UART0_RTSB on PTD4
''''''''''''''''
'UART0_Init_Advanced(9600, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, @_GPIO_Module_UART0_PA1_2)

UART0_C1 = (0x00) or UART0_C1
GPIOE_PSOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7
Delay_ms(5)
UART0_C2 = 0x0C
UART0_C3 = 0x00
UART0_C4 = 0x08
UART0_C5 = 0x00

UART0_BDH = 3
UART0_BDL = 13

PORTA_PCR1 = (3 << 8 )
PORTA_PCR2 = (3 << 8 )
Delay_ms(100)


''''''''''''''''


GPIOE_PSOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7
Delay_ms(1000)
GPIOE_PCOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7
Delay_ms(1000)
GPIOE_PSOR = _GPIO_PINMASK_9 or _GPIO_PINMASK_8 or _GPIO_PINMASK_7

Delay_ms(500)
GPIOE_PCOR = _GPIO_PINMASK_9

while true
if (UART0_Data_Ready() = 1) then
GPIOE_PCOR = _GPIO_PINMASK_7
UART0_Read_Text(dataStr, ";", 50)
UART0_Write_Text(dataStr)


end if
wend
end.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: MCU Hangs on register write

#2 Post by filip » 08 Aug 2022 08:30

Hi,

Can you please put your project in an archive and attach it here ?

Regards,
Filip.

Post Reply

Return to “mikroBasic PRO for ARM General”