Hello,
I am learning how to program my nrf5340DK
I started using the ncs setup but it is too much overhead for me and I wanted to try a more bare setup and I dont mind if I have to work on a low level.
The following seems to work if I only want to operate on register level - trying out the examples in the PS:
1. Download SES and install
2. Download JLink and install
3. Enable nordic and CMIS support packages under Tools -> Package Manager
4. Create a new project for ncs chips selecting nrf5340_xxA_Application as target
These steps seemed to be enough to get started.
Here is an example directly from the datasheet.
I had to change PWM0 to PWM0_NS but it seems to build and upload to the board.
File : main.c
Purpose : Generic application start
*/
#include <nrf5340_application.h>
#include <nrf.h>
#include <nrf5340_application_peripherals.h>
#include <stdio.h>
#include <stdlib.h>
#define PWM_CH0_DUTY 8000
#define PWM_CH1_DUTY 8000
#define PWM_CH2_DUTY 8000
#define PWM_CH3_DUTY 8000
#define first_pin 28 // 0.28 = LED1
#define second_pin 29 // 0.29 = LED2
int main(void) {
uint16_t pwm_seq[4] = {PWM_CH0_DUTY, PWM_CH1_DUTY, PWM_CH2_DUTY, PWM_CH3_DUTY};
NRF_PWM0_NS->PSEL.OUT[0] = (first_pin << PWM_PSEL_OUT_PIN_Pos) |
(PWM_PSEL_OUT_CONNECT_Connected <<
PWM_PSEL_OUT_CONNECT_Pos);
NRF_PWM0_NS->PSEL.OUT[1] = (second_pin << PWM_PSEL_OUT_PIN_Pos) |
(PWM_PSEL_OUT_CONNECT_Connected <<
PWM_PSEL_OUT_CONNECT_Pos);
NRF_PWM0_NS->ENABLE = (PWM_ENABLE_ENABLE_Enabled << PWM_ENABLE_ENABLE_Pos);
NRF_PWM0_NS->MODE = (PWM_MODE_UPDOWN_Up << PWM_MODE_UPDOWN_Pos);
NRF_PWM0_NS->PRESCALER = (PWM_PRESCALER_PRESCALER_DIV_1 <<
PWM_PRESCALER_PRESCALER_Pos);
NRF_PWM0_NS->COUNTERTOP = (16000 << PWM_COUNTERTOP_COUNTERTOP_Pos); //1 msec
NRF_PWM0_NS->LOOP = (PWM_LOOP_CNT_Disabled << PWM_LOOP_CNT_Pos);
NRF_PWM0_NS->DECODER = (PWM_DECODER_LOAD_Individual << PWM_DECODER_LOAD_Pos) |
(PWM_DECODER_MODE_RefreshCount << PWM_DECODER_MODE_Pos);
NRF_PWM0_NS->SEQ[0].PTR = ((uint32_t)(pwm_seq) << PWM_SEQ_PTR_PTR_Pos);
NRF_PWM0_NS->SEQ[0].CNT = ((sizeof(pwm_seq) / sizeof(uint16_t)) <<
PWM_SEQ_CNT_CNT_Pos);
NRF_PWM0_NS->SEQ[0].REFRESH = 0;
NRF_PWM0_NS->SEQ[0].ENDDELAY = 0;
NRF_PWM0_NS->TASKS_SEQSTART[0] = 1;
while(1) {
// Do nothing
};
}
However, LED1 (pin 0.28 or 28 in this example) does not light up.
Any Ideas on what I am missing make the example work?
Thanks
/Jonas