This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue running TWI/SPI on nRF52832, works with Kiel but not GCC

Hi,

Just curious to know if anyone else had this issue and how they solved it.

My colleagues and I are working on code based on the Nordic Uart Service, in SDK13.1.0 with SD132v4.0.2 on an nRF52832 chip. For better context, colleagues develop using Kiel on Windows, where as I am developing on a Mac (NetBeans + GCC setup, GNU_VERSION = 6.3.1).

Our test project interfaces with sensors via TWI and SPI and sends data over BLE. When programmed through kiel, the device works fine (i.e. can set up interfaces, collect data, connect and send data etc.).

The same project when downloaded into my environment, can compile, build and flash code just fine. Except the following:

  • TWI init() works fine.
  • on attempting to initialize the first sensor and writing to it over TWI, the twi handler never gets called, and hence hangs. (e.g. nrf_drv_twi_tx() returns NRF_SUCCESS)

Similar behavior is also seen with the SPI.

I know my development environment works fine when I have to program a PCA10040 dev kit, with code from the example projects for testing. I also have a pretty good understanding of setting up the Makefile and adjusting the RAM allocations through the .ld file. sdk_config.h also has the necessary flags enabled for running the interfaces (else they wouldn't work when programmed through Kiel either). I am confused as to why a project would compile and run fine through Kiel, but will not run the same through GCC.

I have also tried flashing the twi_scanner project to a devkit, without the soft device, which works fine too.

I am guessing that I may be missing something else in my development setup, but it just does not seem obvious to me. I would be glad if some one has found the solution to this before!

Thanks, Jai

Parents
  • There are a few bugs in the .ld for GCC. The new stuffs with Section after the FLASH & RAM setting. Look for > RAM and replace it with '> RAM AT > FLASH'. This affects project using Softdevice. That was one of the problem I found since SDK12.

  • To further clarify, I am flashing and setting the soft device in the makefile commands.

    `.PHONY: $(TARGETS) default all clean help flash_softdevice flash
    
    # Default target - first one defined
    default: nrf52832_xxaa
    
    # Print all targets that can be built
    help:
    	@echo following targets are available:
    	@echo 	nrf52832_xxaa
    
    TEMPLATE_PATH := <path>
    
    include $(TEMPLATE_PATH)/Makefile.common
    
    $(foreach target, $(TARGETS), $(call define_target, $(target)))
    
    # Flash the program
    flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
    	@echo Flashing: $<
    	nrfjprog --program $< -f nrf52 --sectorerase --verify
    	nrfjprog --reset -f nrf52
    
    # Flash softdevice
    flash_softdevice:
    	@echo Flashing: s132_nrf52_4.0.2_softdevice.hex
    	nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_4.0.2_softdevice.hex -f nrf52 --chiperase --verify
    	nrfjprog --reset -f nrf52
    
    erase:
    	nrfjprog --eraseall -f nrf52`
    
Reply
  • To further clarify, I am flashing and setting the soft device in the makefile commands.

    `.PHONY: $(TARGETS) default all clean help flash_softdevice flash
    
    # Default target - first one defined
    default: nrf52832_xxaa
    
    # Print all targets that can be built
    help:
    	@echo following targets are available:
    	@echo 	nrf52832_xxaa
    
    TEMPLATE_PATH := <path>
    
    include $(TEMPLATE_PATH)/Makefile.common
    
    $(foreach target, $(TARGETS), $(call define_target, $(target)))
    
    # Flash the program
    flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
    	@echo Flashing: $<
    	nrfjprog --program $< -f nrf52 --sectorerase --verify
    	nrfjprog --reset -f nrf52
    
    # Flash softdevice
    flash_softdevice:
    	@echo Flashing: s132_nrf52_4.0.2_softdevice.hex
    	nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_4.0.2_softdevice.hex -f nrf52 --chiperase --verify
    	nrfjprog --reset -f nrf52
    
    erase:
    	nrfjprog --eraseall -f nrf52`
    
Children
No Data
Related