We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
posted on 2013/08/08 05:58:50 AM CEST
I need help for the I2C zilog program master and slave function using 3-axis gyroscope. anyone knows a program about this? we really need this for our project study. thanks
posted on 2013/08/01 07:20:13 AM CEST
I have tried a lot to get any of the four possible 16 quad encoder counters (Tim2 -5) running, with no success. Can anyone have a suggestion? See my sample code below.
// --------------- Init encoder
Procedure EncoderInit;
Begin
//Configure peripheral clocks
//Configure pins
GPIO_Config(@GPIOC_BASE, _GPIO_PINMASK_6 or _GPIO_PINMASK_7,
_GPIO_CFG_MODE_INPUT or _GPIO_CFG_PULL_UP or _GPIO_CFG_MODE_ALT_FUNCTION or _GPIO_CFG_SPEED_100MHZ); // Pin ChA and chB config
// GPIO_Config(@GPIOC_BASE, _GPIO_PINMASK_6 or _GPIO_PINMASK_7,
// _GPIO_CFG_MODE_INPUT or _GPIO_CFG_PULL_UP or _GPIO_CFG_SPEED_100MHZ); // Pin ChA and chB config
CEN_TIM3_CR1_bit:=0; // Disable timer
CEN_TIM4_CR1_bit:=0; // Disable timer
AFRL60_GPIOC_AFRL_bit:=0; //GPIOc_AFRH alternate function AF2 for PC6
AFRL61_GPIOC_AFRL_bit:=1;
AFRL62_GPIOC_AFRL_bit:=0;
AFRL63_GPIOC_AFRL_bit:=0;
AFRL70_GPIOC_AFRL_bit:=0; //GPIOc_AFRH alternate function AF2 for PC7
AFRL71_GPIOC_AFRL_bit:=1;
AFRL72_GPIOC_AFRL_bit:=0;
AFRL73_GPIOC_AFRL_bit:=0;
TIM3_ARR:=3000;
TIM4_ARR:=3000;
CC1S0_TIM3_CCMR1O_bit:=1; // Tim3_CCMR1 input mapping T1 map
CC1S1_TIM3_CCMR1O_bit:=0;
CC2S0_TIM3_CCMR1O_bit:=1; // Tim3_CCMR1 input mapping T2 map
CC2S1_TIM3_CCMR1O_bit:=0;
//Configure Timer
CC1P_TIM3_CCER_bit:=0; // Tim3_CCER Input polarity
CC2P_TIM3_CCER_bit:=0;
//Debounce filter
//Setup quadrature encoder and enable timer
// TIM3_SMCR
// Main Configuration of Timer 3: Tim3_SMCR.SMS -> Encoder Mode 3 (val 011)
SMS0_TIM3_SMCR_bit:=1; // Count on edge ch1
SMS1_TIM3_SMCR_bit:=1; // and channel 2
SMS2_TIM3_SMCR_bit:=0;
// SMS2_TIM3_SMCR_bit:=0;
ETF0_TIM3_SMCR_bit:=1;
ETF1_TIM3_SMCR_bit:=1;
ETF2_TIM3_SMCR_bit:=1;
ETF3_TIM3_SMCR_bit:=1;
// CC2P= ‘0’, CC2NP = ‘0’, IC2F =’0000’ (TIMx_CCER register, TI2FP2 noninverted, TI2FP2=TI2)
//Tim3_SMCR.TS -> TI1FP1 (val 101)
//Tim3_CR1.URS -> Counter over-/underflow, UG BIT, Slave mode controller (val 0)
//Tim3.ARR -> 1000
//Timer 3 Channel 1 Configuration: Tim3_CCR1 -> 0
//Tim3_CCMR1.CC1S -> CC1 configured as input, IC1 mapped on TI1 (val 01)
//Tim3_CCER.CC1P -> non-inverted (val 0)
//Timer 3 Channel 2 Configuration: Tim3_CCR2 -> 0
//Tim3_CCMR1.CC2S -> CC2 configured as input, IC2 mapped on TI2 (val 01)
//Tim3_CCER.CC2P -> non-inverted (val 0)
CEN_TIM3_CR1_bit:=1; // Enable timer
End; // Encoderinit
Function Getcount: word;
var a: integer;
begin
CEN_TIM3_CR1_bit:=0; // Enable timer
TIM3_CNT:=222;
CEN_TIM3_CR1_bit:=1; // Enable timer
GetCount:=TIM3_CNT;
// a:=__System_CLOCK_IN_KHZ;
// Getcount:=a;
end;
posted on 2013/07/30 01:45:01 PM CEST
i want to use orther pin in soft Uart code.but not work.this code:
char i, error, byte_read; // Auxiliary variables
void main(){
UART1_Init(9600);
error = Soft_UART_Init(&GPIOA_ODR, 7, 6, 9600, 0); // Initialize Soft UART at 56000 bps
if (error > 0) {
GPIOD_ODR = error; // Signalize Init error
while(1); // Stop program
}
Delay_ms(100);
while(1)
{ // Endless loop
// Send bytes from 'z' downto 'A'
Soft_UART_Write('a');
Delay_ms(100);
byte_read = Soft_UART_Read(&error); // Read byte, then test error flag
if (error) // If error was detected
GPIOD_ODR = error; // signal it on PORTD
else
//Soft_UART_Write(byte_read); // If error was not detected, return byte read
UART1_Write(byte_read);
}
}
Uart1 is hard uart.
posted on 2013/07/30 08:42:30 AM CEST
A library to use these Pic family internal RTC would be very useful. I use MikroBasic.
Thanks
posted on 2013/07/25 04:32:54 AM CEST
Hi,
Looking for examples for ConnectEVE TFT screen and ATmega32, I have an easyAVR development board but havent been able to find code samples for atmega32, have only found for xmega controllers
Thanks