Imam seminarski za obraditi o digitalnom potenciometru tvrtke mikroelektronika i ja sam obradio teorijsku pozadinu pa sam htio pitati na stranici od plocice ima primjer za avr EasyAvr6 razvojnu plocu pa sam htio pitati da li ce isti program raditi i na atmelovoj STK-500 razvojnoj ploci? Zahvaljujem
Code: Select all
/*
* Project name:
Digital Potentiometer
* Copyright:
(c) Mikroelektronika, 2011.
* Revision History
20110308:
- initial release(SZ);
* Description:
This program demonstrates the usage of Digital Potentiometer Board (MCP41010).
Voltage derived from PW pin is read by MCU's ADC (ADC0). Scaled value is then displayed at PORTD LEDs.
It's all happening in an endless loop.
* Test configuration:
MCU: ac:ATMega16
http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
Dev.Board: ac:EasyAVR6
http://www.mikroe.com/eng/products/view/321/easyavr6-development-system/
Oscillator: HS, 08.0000 MHz
Ext. Modules: ac:Digital_Potentiometer
http://www.mikroe.com/en/tools/digitalpot/
SW: mikroC PRO for AVR
http://www.mikroe.com/eng/products/view/228/mikroc-pro-for-avr/
* NOTES:
- Digital Potenciometer Board must be connected on PORTB (SW1.3, SW1.6 and SW1.7 - ON).
- Connect PA to Vcc, PB to Gnd and PW to PA0 pin.
- Don't use pull-up(down) resistor at PA0 pin.
- Turn ON PORTD LEDs (SW8.4).
*/
sbit DigPot_CS at PORTB0_bit;
sbit DigPot_CS_Direction at DDB0_bit;
unsigned int adc_value;
unsigned short counter = 0;
void InitMain() {
DDA0_bit = 0; // Set RA0 as input
DigPot_CS_Direction = 1; // Set RB0 pin as output
DDRD = 0xFF; // PORTD is output
ADC_Init(); // Initialize ADC module
SPI1_Init(); // Initialize SPI module
}
void main() {
InitMain(); // Perform main initialization
Delay_ms(100);
while (1) { // Endless loop
DigPot_CS = 0; // Select PotentioMeter chip
SPI1_Write(0b00010001); // Issue COMMAND Write data
SPI1_Write(counter); // Send DATA byte
DigPot_CS = 1; // Deselect PotentioMeter chip
adc_value = ADC_Get_Sample(0); // Get 10-bit results of AD conversion
PORTD = adc_value >> 2; // Scale it (divide by 4) and display it at PORTD LEDs
Delay_ms(50);
if (counter++ == 255) counter = 0;
}
}
http://www.mikroe.com/add-on-boards/var ... ntiometer/
Zahvaljujem