Hi all,
I am trying to set up UART communication on the nrf9160. I am using the nrf9160 DK and zephyr.
I have selected device UART_1 and after I cal functions device get_binding() and uart_configure() I can send data over the the virtual port VCOM2.
However TX pin P0.01 stays LOW all the time. Does anybody know anything about this issue?
nrf9160_pca.dts_compliled snippet
uart1: uart@9000 {
compatible = "nordic,nrf-uarte";
reg = < 0x9000 0x1000 >;
interrupts = < 0x09 0x01 >;
status = "okay";
label = "UART_1";
current-speed = < 0x1c200 >;
tx-pin = < 0x01 >;
rx-pin = < 0x00 >;
rts-pin = < 0x0e >;
cts-pin = < 0x0f >;
};
proj.config snippet:
CONFIG_SERIAL=y CONFIG_TRUSTED_EXECUTION_NONSECURE=y CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_UART_0_NRF_UARTE=y CONFIG_UART_1_NRF_UARTE=y
struct device *uart_dev;
void uart_init(void){
int err=0;
struct uart_config uart_settings;
uart_dev = device_get_binding(UART_NAME);
if(uart_dev == NULL){
printk("error:could not get %s binding\n",UART_NAME);
return;
}
uart_settings.baudrate = 115200;
uart_settings.parity = UART_CFG_PARITY_NONE;
uart_settings.stop_bits = UART_CFG_STOP_BITS_1;
uart_settings.data_bits = UART_CFG_DATA_BITS_8;
uart_settings.flow_ctrl = UART_CFG_FLOW_CTRL_NONE;
err = uart_configure(uart_dev,&uart_settings);
if(err == 0){
printk("configured uart\n");
printk("Value of NRF_UARTE1_NS->PSEL.RXD: %lu \n", (unsigned long)NRF_UARTE1_NS->PSEL.RXD);
printk("Value of NRF_UARTE1_NS->PSEL.TXD: %lu \n", (unsigned long)NRF_UARTE1_NS->PSEL.TXD);
}
else{
printk("error could not configure uart\n");
}
}
int main(void) {
printk("Starting application\n");
uart_init();
u8_t string[] ="AWAKE\r\n";
u8_t* test_ptr = string;
while (true) {
for(int i=0; i<sizeof(string);i++){
uart_poll_out(uart_dev,*test_ptr);
//printk("%c",*test_ptr);
test_ptr++;
}
test_ptr = string;
k_sleep(100);
}
return 0;
}