JN5169 UART1 SEND DATA

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JN5169 UART1 SEND DATA

2,426 Views
fangliang2316
Contributor I

Hi,

I am working with the ZigBee HA Intruder Alarm System.  I am working with JN-AN-1201.

I need to communicate with another MCU through uart1. Where do I need to configure and modify?

0 Kudos
Reply
10 Replies

2,044 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Liang, I hope you're doing well!

 

To add functionality for UART1, you first need to set it up, and you can do so in the APP_vInitialise part of your program (inside the app_start.c source file). You can base your initialization on the implementation for UART0 in the JN-AN-1217 Application note.

You'll have to create a new function based on the existing UART_vInit, but adapt the macros so it enables UART1 instead of UART0.

 

If you have any further questions, please let me know.

 

Best regards,

Sebastian

0 Kudos
Reply

2,044 Views
fangliang2316
Contributor I

Hi Sebastian,

Thanks for reply!

We are now developing on the basis of JN-AN-1217. JN-AN-1201 and JN-AN-1217 are different software architectures. I'll do the following directly. uart1 still can't send data. Can I give some suggestions based on JN-AN-1201?

PUBLIC void UART_vInit(void)
{
bAHI_UartEnable(E_AHI_UART_1, txbuf,(uint8)16, rxbuf, (uint8)127); 

vAHI_UartReset(E_AHI_UART_1, TRUE, TRUE);
vAHI_UartReset(E_AHI_UART_1, FALSE, FALSE);


UART_vSetBaudRate(E_AHI_UART_RATE_9600);
vAHI_UartSetControl(E_AHI_UART_1, FALSE, FALSE, E_AHI_UART_WORD_LEN_8, TRUE, FALSE); 
vAHI_UartSetInterrupt(E_AHI_UART_1, FALSE, FALSE, FALSE, TRUE, E_AHI_UART_FIFO_LEVEL_1); 

}


My requirement is that UART0 output log, uart1 communicate with another MCU。

Best regards,

Liang

0 Kudos
Reply

2,044 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Liang,

 

Could you please try checking the corresponding DIO pins for UART1 with a logic analyzer to see if they're outputting anything?

 

The pins for UART1 are:

DIO17: UART1 Clear to Send

DIO18: UART1 Request to Send

DIO19: UART1 TX

DIO20: UART1 RX

 

Please let me know of your results.

 

Best regards,

Sebastian

 

0 Kudos
Reply

2,044 Views
fangliang2316
Contributor I

Hi Sebastian,

Thanks for your for reply.

Maybe I didn't have to describe it clearly. The chip model I chose was JN5169.

according to data sheet,the pins for uart1:

DIO14:UART TX

DIO15:UART1 RX

I have checked DIO14 pins and DIO11  pins,No data output.

0 Kudos
Reply

2,044 Views
fangliang2316
Contributor I

Hi Sebastian,

Here is a supplementary description of the problems I encountered.

 

SDK:               JN-SW-4168

example:         AN-JN-1201

chip:             JN5169

part A:

It is from JN-AN-1201,UART0 for log :

vAHI_UartSetRTSCTS(E_AHI_UART_0, FALSE);

DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200);

The log is ok

part  B:

I want to add uart1 to communicate with another MCU.

void driver_uart1_init (void)
{
bAHI_UartEnable(E_AHI_UART_1,UART1_TX_BUFF,100,UART1_RX_BUFF,100);

vAHI_UartReset(E_AHI_UART_1, TRUE, TRUE);
vAHI_UartReset(E_AHI_UART_1, FALSE, FALSE);


UART_vSetBaudRate(E_AHI_UART_RATE_115200);


vAHI_UartSetControl(E_AHI_UART_1, FALSE, FALSE, E_AHI_UART_WORD_LEN_8, TRUE, FALSE); 
vAHI_UartSetInterrupt(E_AHI_UART_1, FALSE, FALSE, FALSE, TRUE, E_AHI_UART_FIFO_LEVEL_1);

}

I doubt if there is a conflict between these two parts,part A  and  part  B.

Best regards,

Liang

0 Kudos
Reply

2,044 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Liang,

 

I'm sorry, I got confused with the default pin location of UART1 in the JN5169. The default pins are the ones you mentioned (DIO14 and DIO15).

 

The UART1 and UART0 setup shouldn’t interfere with each other. Could you please make sure that you're enabling and setting the priority of the UART1 interrupt correctly in the irq_JN516x.S file?

 

For example:

    .byte 0                 # PHY priority
    .byte 5                 # uart0 priority
    .byte 0                 # uart1 priority 
.globl  PIC_SwVectTable
    .section .text,"ax"
    .extern zps_isrMAC
    .extern ISR_vTickTimer
    .extern APP_isrUart
    .align 4
    .type   PIC_SwVectTable, @object
    .size   PIC_SwVectTable, 64 
    .word vUnclaimedInterrupt               # 2
    .word vUnclaimedInterrupt               # 3
    .word vUnclaimedInterrupt               # 4
    .word APP_isrUart                       # 5
    .word vUnclaimedInterrupt               # 6 
 

 …

 

 

Also, could you please check if the UART1 pins are on high to check if the pins are set correctly?

 

Best regards,

Sebastian

0 Kudos
Reply

2,044 Views
fangliang2316
Contributor I

Hi Sebastian,

I have checked UART1 pins,they are on high.

I confirm that I have set the priority level for UART1 in os_irq.s  file(I coundn't find irq_5169.s  in JN-AN-1201).

1234.png

in the   file  App_ZHA_ZONE_JN516x.oscfgdiag, I config the Uart1 interrrupt.

10000.png

I have a question about how to configure the parameters in Makefile  file.

###############################################################################
# End device or router / coord (e.g. ZCR, ZED)
ZBPRO_DEVICE_TYPE ?= ZED

###############################################################################
# Debug options define DEBUG either HW or SW
#DEBUG ?=SW
#DEBUG ?=HW
#
# Define which UART to use for HW debug
#DEBUG_PORT ?= UART0


###############################################################################
# Define TRACE to use with DBG module
TRACE ?= 1
ifeq ($(TRACE), 1)
#CFLAGS += -DDBG_ENABLE
endif

APP_CLUSTERS_IAS_SRC ?=1

CFLAGS += -D$(TARGET)
CFLAGS += -DUART=1 #add
##############################################################################

0 Kudos
Reply

2,044 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Liang,

 

Could you check to see if you added the priority in the "os_PIC_ChannelPriorities" section if the .s file?

 

Also, could you try adding this to the bottom of your file?

 

os_vISR_Uart1_J:
    b.ori  r3,r0,os_vISR_Uart1
    b.ja   os_vISR_Uart1

 

Are you interested in the IAS profile?

Do you want to enroll your devices?

 

Best regards,

Sebastian

0 Kudos
Reply

2,044 Views
fangliang2316
Contributor I

Hi Sebastian,

This is my os_irq.s  file:

/*begain*/

.section .text,"ax"
.globl os_ExternalException_W
.globl os_ExternalException_R

.extern os_PIC_SwVectTable

# Controlled interrupt wrapper
# sits on external interrupt exception
# stores minimal context before re-enabling interrupts via global diable flag
# branches through PIC software vector table using IPL register from PIC
# [I SP001271_fr 404,405,406,407,408] begin
.align 8
os_ExternalException_W:
b.addi r1,r1,-24
b.sw 0(r1),r3
b.sw 4(r1),r4
b.sw 20(r1),r9
bw.mfspr r9,r0,0x0020 # get EPCR0
b.sw 8(r1),r9 # stack EPCR0
bw.mfspr r3,r0,0x0040 # get ESR0
b.sw 12(r1),r3 # stack ESR0

bw.mfspr r3,r0,0x4810 # get IPMR
b.sw 16(r1),r3 # stack IPMR

bw.mfspr r4,r0,0x4811 # get IHPR
bw.mtspr r0,r4,0x4810 # write to IPMR

b.ei # enable interrupts

b.slli r4,r4,2 # vector through pseudo vector table for PIC interrupt sources
b.addi r4,r4,os_PIC_SwVectTable
b.lwz r4,0(r4)
b.jalr r4
# [I SP001271_fr 404,405,406,407,408] end

.globl os_PIC_ChannelPriorities
.section .text,"ax"
.align 4
.type os_PIC_ChannelPriorities, @object
.size os_PIC_ChannelPriorities, 16
os_PIC_ChannelPriorities:
.byte 14
.byte 0
.byte 1
.byte 7
.byte 0
.byte 0
.byte 0
.byte 5     /*the priority of uart1*/
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 15

.globl os_OSMIUM_HwVectTable
.extern os_UnclaimedException_W
.extern os_UnclaimedInterrupt_W
.extern os_ExternalException_W

.section .text,"ax"
.align 4
.type os_OSMIUM_HwVectTable, @object
.size os_OSMIUM_HwVectTable, 78
os_OSMIUM_HwVectTable:
b.ja IRQ_BusError
b.ja os_UnclaimedException_W
b.ja IRQ_Alignment
b.ja IRQ_IllegalInstruction
b.ja os_ExternalException_W
b.rfe
b.nop
b.nop
b.ja os_UnclaimedException_W
b.ja IRQ_UnimplementedModule
b.ja os_UnclaimedException_W
b.ja IRQ_StackOverflowException

.globl os_PIC_SwVectTable
.section .text,"ax"
.align 4
.type os_PIC_SwVectTable, @object
.size os_PIC_SwVectTable, 64
os_PIC_SwVectTable:
.word os_UnclaimedInterrupt_W
.word os_vISR_SystemController_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_APP_IsrUart1_W
.word os_UnclaimedInterrupt_W
.word os_zps_isrMAC_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_UnclaimedInterrupt_W
.word os_APP_IsrTimer1_W
.word os_APP_isrTickTimer_W

.section .text,"ax"
.align 4
.extern os_ExternalException_R
.extern os_CFunc_W
.extern os_vControlledInterrupt
.extern os_vControlledIntCheck

.extern os_vvISR_SystemController
os_vISR_SystemController_W:
b.addi r1,r1,-8
b.sw 0(r1),r9
b.sw 4(r1),r5
b.ori r4,r0,os_vISR_SystemController_J
b.ori r5,r0,os_vControlledInterrupt
b.jal os_CFunc_W
b.lwz r9,0(r1)
b.lwz r5,4(r1)
b.addi r1,r1,8
b.ja os_ExternalException_R
os_vISR_SystemController_J:
b.ori r3,r0,os_vvISR_SystemController
b.ja os_vControlledIntCheck

.extern os_vAPP_IsrUart1
os_APP_IsrUart1_W:
b.addi r1,r1,-8
b.sw 0(r1),r9
b.sw 4(r1),r5
b.ori r4,r0,os_APP_IsrUart1_J
b.ori r5,r0,os_vControlledInterrupt
b.jal os_CFunc_W
b.lwz r9,0(r1)
b.lwz r5,4(r1)
b.addi r1,r1,8
b.ja os_ExternalException_R
os_APP_IsrUart1_J:/*os_APP_IsrUart1_J*/
b.ori r3,r0,os_vAPP_IsrUart1
b.ja os_vControlledIntCheck

.extern os_vzps_isrMAC
os_zps_isrMAC_W:
b.addi r1,r1,-8
b.sw 0(r1),r9
b.sw 4(r1),r5
b.ori r4,r0,os_zps_isrMAC_J
b.ori r5,r0,os_vControlledInterrupt
b.jal os_CFunc_W
b.lwz r9,0(r1)
b.lwz r5,4(r1)
b.addi r1,r1,8
b.ja os_ExternalException_R
os_zps_isrMAC_J:
b.ori r3,r0,os_vzps_isrMAC
b.ja os_vControlledIntCheck

.extern os_vAPP_IsrTimer1
os_APP_IsrTimer1_W:
b.addi r1,r1,-8
b.sw 0(r1),r9
b.sw 4(r1),r5
b.ori r4,r0,os_APP_IsrTimer1_J
b.ori r5,r0,os_vControlledInterrupt
b.jal os_CFunc_W
b.lwz r9,0(r1)
b.lwz r5,4(r1)
b.addi r1,r1,8
b.ja os_ExternalException_R
os_APP_IsrTimer1_J:
b.ori r3,r0,os_vAPP_IsrTimer1
b.ja os_vControlledIntCheck

.extern os_vAPP_isrTickTimer
os_APP_isrTickTimer_W:
b.addi r1,r1,-8
b.sw 0(r1),r9
b.sw 4(r1),r5
b.ori r4,r0,os_APP_isrTickTimer_J
b.ori r5,r0,os_vControlledInterrupt
b.jal os_CFunc_W
b.lwz r9,0(r1)
b.lwz r5,4(r1)
b.addi r1,r1,8
b.ja os_ExternalException_R
os_APP_isrTickTimer_J:
b.ori r3,r0,os_vAPP_isrTickTimer
b.ja os_vControlledIntCheck

/*end*/

I use the IAS profile  and I enroll my devices.

 

I succeeded in exporting debugging logs separately through UART0 or uart1. But I output logs through uart0, and through uart1 communicating with PC or mcu, uart1 cannot output data.Could you confirm this question, based on

JN-AN-1201.Thanks!

Best regards,

Liang

0 Kudos
Reply

2,044 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Liang,

 

Could you please try changing the vISR_Uart1 to APP_isrUart?

In the function, you'll have to specify which UART you'll be using to communicate:

 

PUBLIC void APP_isrUart(void)
{
    unsigned int irq = ((*((volatile uint32 *)(UART_START_ADR + 0x08))) >> 1) & 0x0007;
    uint8 u8Byte;
 
    if (irq & E_AHI_UART_INT_RXDATA) {
        uint8 u8Byte = u8AHI_UartReadData(UART);
        if(ZQ_bQueueSend(&APP_msgSerialRx, &u8Byte) == FALSE)
        {
            /* Failed to send the message to queue */
        }
    }
 
    if (irq & E_AHI_UART_INT_TX) {
        if(ZQ_bQueueReceive(&APP_msgSerialTx, &u8Byte) == TRUE)
        {
            vAHI_UartWriteData(UART, u8Byte);
            /* decrement activity counter for dequeued data */
        } else {
            /* disable tx interrupt as nothing to send */
            UART_vSetTxInterrupt(FALSE);
        }
    }
}

 

Also, can you send data if you're not using the debug?

 

Please let me know if that works.

 

Best regards,

Sebastian

0 Kudos
Reply