Atmega32U4 PF4-PF7 always active high - Page 1
Forum section: electronics / general

author: trini8ed
author_rank: Newbie
timestamp: November 18, 2020, 01:06:56 am
content: Hello everyone I've been working on a circuit to test external circuit propagation delays. I've been stumped with trying to figure out why if I setup PORTF as outputs always drive active high regardless of what the chips programmed to do for the Atmega32U4. The code was programmed on using USBasp using ISP.Things I have Tried:1) Checked for shorts to GND or +5V between each PORTF pin.2) Checked for shorts between PORTF pins to other PORTF pins.3) Soldered on a new Atemga32U4 chip same issue persists.4) Manually drove the segments that won't turn on (They were able to be driven)After replacing the Atemga32U4 chip the same exact result happened making me feel that the issue is perhaps incorrectly setting up a register for PORTF and DDRF somehow.Code:Code:// HARDWARE SETUP:// Segments are hooked up// PORTA -------------------------------------------------------------------------------------------------------// PORTA0-7 are connected to the segments of the LED display.// PORTB -------------------------------------------------------------------------------------------------------// PORTB6 goes to the A selector on our 74LVC1G139 decoder for our units LED's// PORTB7 goes to the B selector on our 74LVC1G139 decoder for our units LED's// PORTD -------------------------------------------------------------------------------------------------------// PORTD0 is used as an interrupt to detect when the output signal has propagated through to stop the timer// PORTD1 is used as an interrupt to detect when the relay is latched and starts the timer// PORTD2 is used as an interrupt to detect a button press and turn on the relay// PORTD6 goes to the A selector on our 74LVC1G139 decoder for our segment digit select// PORTD7 goes to the B selector on our 74LVC1G139 decoder for our segment digit select// PORTF & PORTC -----------------------------------------------------------------------------------------------// PORTF0 is used as an output for our segment for A// PORTF1 is used as an output for our segment for B// PORTC6 is used as an output for our segment for C// PORTC7 is used as an output for our segment for D// PORTF4 is used as an output for our segment for E// PORTF5 is used as an output for our segment for F// PORTF6 is used as an output for our segment for G// PORTF7 is used as an output for our segment for DP// library includes#include <avr/io.h>#include <avr/interrupt.h>#include <util/delay.h>#define DIG_A 6#define DIG_B 7#define DIG_SEL 6int main(){// setup our PORTC and PORTF// --------------------------------------// setup PORTF as outputsDDRF = 0xFF;// set default value to all be on for our segmentsPORTF = 0x00;// setup PORTC as outputsDDRC = 0xFF;// set default value to all be on for our segmentsPORTC = 0x00;// setup PORTs??// --------------------------------------DDRD = 0xFF;PORTD = 0x00;DDRB = 0xFF;PORTB = 0x00;//sei(); // enable interrupts before entering loopwhile (1){// break up the disp_value to 4, BCD digits in the array: call (segsum)//segment_sum(count);// bound a counter (0-4) to keep track of digit to displayuint8_t index;for (index = 0x00; index < 4; index++){// send 7 segment code to LED segmentsPORTF = 0x00;PORTC = 0x00;// save state of port buint8_t tempB = PORTB;// clear the S0, S1, S2 selector bits and keep temptempB &= !((1 << DIG_A) | (1 << DIG_B));// save our new digit to our combined temp variabletempB |= (index << DIG_SEL);// overwrite portb with our new variablePORTB = tempB;// delay to have the screen get enough power_delay_us(500);}} // whilereturn 0;} // mainSchematic:In attachmentsPicture:In attachments

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 18, 2020, 01:17:40 am
content: Disable JTAG fuses.Tim

author: trini8ed
author_rank: Newbie
timestamp: November 18, 2020, 01:46:50 am
content: Amazing I think it was to late for me to find that MCUCR register and set the JTD bit to a 1 to disable it. I saw that it used JTAG but yeah it was that 2-3am datasheet scouring trying to find out where to disable it

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 18, 2020, 03:48:13 am
content: This bit me in recent memory, not sure if the particular chip I used didn't happen to have its fuses set consistently with others, or if I just wasn't using PORTF before... needless to say, after some time verifying the port and pin states, inspecting the datasheet, and finally reading the fuse bits, I found the problem.Tim