borge
Junior Member level 1
- Joined
- Jan 4, 2013
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Norway
- Activity points
- 1,375
Hi
I am new to microcontrollers, and programming. But have basic skills in electronics.
I have buildt a Digital multiple powersupply with the Att2313. https://www.electronics-lab.com/projects/power/020/index.html
I programmed the att2313 with my programmer (willem PCB50B ) and it verified it as ok. I used the ICSP connection.
But it doesnt work, i checked the circuit, and all is ok.
I checked the C code in DEV-C++ and it found errors ??
I Hope somone can verify the code for me, so i know if i need to program again, i might have wrong settings when programming
The code.
Thanks
Børge
- - - Updated - - -
Thanks alexan_e, i should have read the posting rules first.
Are you able to se if this code is ok.
Børge
I am new to microcontrollers, and programming. But have basic skills in electronics.
I have buildt a Digital multiple powersupply with the Att2313. https://www.electronics-lab.com/projects/power/020/index.html
I programmed the att2313 with my programmer (willem PCB50B ) and it verified it as ok. I used the ICSP connection.
But it doesnt work, i checked the circuit, and all is ok.
I checked the C code in DEV-C++ and it found errors ??
I Hope somone can verify the code for me, so i know if i need to program again, i might have wrong settings when programming
The code.
Code:
/*
MCU Power Supply
3/7/2010 BEER-WARE LICENSE
Garrett Fogerlie wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return
AtTiny2313 @ internal 4Mhz
*/
#include <avr/io.h>
#define F_CPU 4000000UL
#include <util/delay.h>
uint8_t buttons;
uint8_t outPin = 1;
int main(void)
{
while(1)
{
buttons = (PIND & 0x0C);// This will store the value of PD2 and PD3 (PD2=0x04, and PD3=0x08, so together it's 0x0C)
_delay_ms(35);// A small debounce delay
if(buttons == 0x04)// If PD2 (-) was pressed
{
if(outPin == 0x01)// If its at its lowest value and DOWN is pressed,
{
outPin = 0x10;// roll over to the highest value (0x10)
}
else // If its not at its lowest value
{
outPin >>= 1;// lower it by a power of 2 (bit shift it to the right by 1)
}
PORTB = outPin;// Set the output port to our outPin value (this will make it output high on the pin that corresponds to outPin's value)
}
if(buttons == 0x08)// If PD3 (+) was pressed
{
if(outPin == 0x10)// If its at its highest value and UP is pressed,
{
outPin = 0x01;// roll over to the lowest value (0x01)
}
else // If its not at its highest value
{
outPin <<= 1;// lower it by a power of 2 (bit shift it to the right by 1)
}
PORTB = outPin;// Set the output port to our outPin value (this will make it output high on the pin that corresponds to outPin's value)
}
}
return 0;
}
Thanks
Børge
- - - Updated - - -
Thanks alexan_e, i should have read the posting rules first.
Are you able to se if this code is ok.
Børge
Last edited by a moderator: