This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: Launchpad throws exception when trying to read ADC register

Part Number: TM4C123GH6PM

Hi,

I'm having some trouble with the TIVAware library functions on the launchpad board. Initially the ADC functions could not be found, but the sysctl functions could, so it wasn't a path problem. However I got around that by finding the source code and taking a copy of it and putting it in my project source directory. It now builds, but throws an exception on the first ADC function call.

In the function below the commented out line is the original TI code. In order to try to debug this I rewrote it using standard C code (rather than a macro). The line highlighted in blue is where the code crashes.

When I try to execute the highlighted line it jumps immediately to FaultISR. However if I change that line to read ADC0_CTL_R = 1, it accepts that line and crashes on the next.

Why would reading a register cause an exception, when writing to it doesn't?

  • Hello Andy,

    Have you enabled the ADC properly with 

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

    That is required. If you hit a fault ISR, you likely did not enable the peripheral before trying to access it.

  • Andy Worsley89 said:
    Initially the ADC functions could not be found, but the sysctl functions could, so it wasn't a path problem.

    Also that doesn't sound correct, you should not need to add those files in the way you described. Did you start a project from Project0 or another TivaWare project? If not you need to make sure your linking is correct so you can use include directives like:

    #include "driverlib/adc.h"

  • You were right about starting up the device. That fixed the problem.

    I started from a blank sheet. It finds the header file, but not the actual function. I presume the SysCtl functions are in the same library.

  • Hello Andy,

    You probably did not link driverlib.lib to your project then. You would need to include the include path for TivaWare, and add the library file to your project. Make sure to do that step as well and then you won't need to add files manually like you had described.