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.

Problem in viewing the led signals on Hardware

Hi,

       I am using Tiva C Series (tm4c123gxl) launchpad and Keil IDE. My plan is to toggle the led's connected to PORTD in particular format. I had given the proper settings to the GPIO registers and getting output in the Keil Logic analyzer,but when checked in the hardware, the PD0 and PD7 signals are not getting the proper magnitude and rest of the signals are getting correctly. I had given the code and I want to know whether is it a problem on the register settings or some where else in the coding or can be a hardware fault?

Here is my code

      
volatile unsigned long delay;
    sysctl_rcgc2_r = 0x00000008;
    delay = sysctl_rcgc2_r;
    gpio_portd_lock_r =    0x4C4F434B;
    gpio_portd_cr_r = 0xFF;
    gpio_portd_dir_r = 0xFF;
    gpio_portd_afsel_r=0x00;
    gpio_portd_pctl_r=0x00000000;
    gpio_portd_amsel_r=0x00;
    gpio_portd_pur_r = 0x80;
    gpio_portd_den_r=0xFF;
     while(1){
        
        
            if(z==0)
            gpio_portd_data_r=0x05;
            for(z=0;z<1508;z++)
            gpio_portd_data_r=(1<<0)+(0<<1)+(1<<2)+(0<<3)+(0<<4)+(0<<5)+(0<<6)+(0<<7);

            for(z=1508;z<1717;z++)
            gpio_portd_data_r=(0<<0)+(0<<1)+(1<<2)+(1<<3)+(0<<4)+(0<<5)+(0<<6)+(1<<7);

  • Hello Nithin,

    Instead of using + operator please use the | operator.

    Secondly please check the ODR register as well. It should be set to 0 as well.

    Also a simpler way of checking the operation of the code is to toggle all the Port D Pins High and Low together to see if the IO Pins show 3.3V

    Regards

    Amit

  • nithin kurian said:
    the PD0 and PD7 signals are not getting the proper magnitude

    Might that PD7 "default" to NMI have claimed (yet another) victim?

    Choice/use of direct register complicates (rather than eases) the job of "would be" helpers...

  • Exactly what signals are you getting wrong and how?

    Robert

  • Amit Ashara said:

    Instead of using + operator please use the | operator.

    The use of manifest constants is also recommended as a good programming practice.

    However, both + and | will produce the same results as long as the same bit is not set on both sides of the operator.

    It's quite obvious in this narrow case that there are no duplicated bits. That said I would not be happy seeing the + operator in production code. I'd be more unhappy with the lack of {} in the loops.

    Robert

  • cb1_mobile said:

    the PD0 and PD7 signals are not getting the proper magnitude

    Might that PD7 "default" to NMI have claimed (yet another) victim?

    [/quote]It's a gift that keeps on giving.

    Robert