bigal_scorpio
Active Member
Hi to all,
Can anyone help me with a problem I have in changing the PIC16F877A that this uses code to a 12F683.
I have looked at the datasheets and the 683 seems to have all it needs but I am absolutely stuck with the different terminology used for the 12Fs to all the other 16F, 18F PICs.
There must be something I'm missing here but why didn't they simply assign the 683 with PORTA instead of the GPIO terminology to keep all the syntax the same?
I just thought I was learning a little when I needed to use a 683 and it all falls to pieces. The only decent examples for programs in the MEBasic are all for the larger PICs, with very little about the 12Fs and even then only the most basic of programs with not much hope of me learning from them.
If anyone could show me how to migrate this program or indeed give me an example of another MEBasic program for both 12F and 16F that I could compare then I would be very grateful and it would help my learning along nicely.
Thanks for looking.........Al
Can anyone help me with a problem I have in changing the PIC16F877A that this uses code to a 12F683.
I have looked at the datasheets and the 683 seems to have all it needs but I am absolutely stuck with the different terminology used for the 12Fs to all the other 16F, 18F PICs.
There must be something I'm missing here but why didn't they simply assign the 683 with PORTA instead of the GPIO terminology to keep all the syntax the same?
I just thought I was learning a little when I needed to use a 683 and it all falls to pieces. The only decent examples for programs in the MEBasic are all for the larger PICs, with very little about the 12Fs and even then only the most basic of programs with not much hope of me learning from them.
If anyone could show me how to migrate this program or indeed give me an example of another MEBasic program for both 12F and 16F that I could compare then I would be very grateful and it would help my learning along nicely.
Code:
' *
' * Project name
' PWM_Test_01 (PWM1 library Demonstration)
' * Copyright
' (c) mikroElektronika, 2008
' * Revision History
' 20080225
' - initial release.
' * Description
' This is a simple demonstration of PWM1 library, which is being used for
' control of the PIC's CCP module. The module is initialized and started,
' after which the PWM1 Duty Ratio can be adjusted by means of two buttons
' connected to pins RA0 and RA1. The changes can be monitored on the CCP
' output pin (RC2).
' * Test configuration
' MCU: PIC16F877A
' Dev.Board: EasyPIC5
' Oscillator: HS, 08.0000 MHz
' Ext. Modules: -
' SW: mikroBasic v7.1
' * NOTES
' - Pull-down PORTA and connect button jumper (jumper17) to Vcc. (board specific)
'*
program PWM_Test_01
dim current_duty, old_duty as byte
sub procedure InitMain()
PORTA = 255
TRISA = 255 ' configure PORTA pins as input
PORTB = 0 ' set PORTB to 0
TRISB = 0 ' designate PORTB pins as output
ADCON1 = 7 ' all ADC pins to digital I/O
PORTC = 0 ' set PORTC to 0
TRISC = 0 ' designate PORTC pins as output
PWM1_Init(5000) ' Initialize PWM1 module at 5KHz
end sub
main:
initMain()
current_duty = 16 ' initial value for current_duty
old_duty = 0 ' old_duty will keep the 'old current_duty' value
PWM1_Start() ' start PWM1
while TRUE
' endless loop
if (Button(PORTA, 0,1,1)) then ' button on RA0 pressed
Inc(current_duty) ' increment current_duty
end if
if (Button(PORTA, 1,1,1)) then ' button on RA1 pressed
Dec(current_duty) ' decrement current_duty
end if
if (old_duty <> current_duty) then ' if change in duty cycle requested
PWM1_Change_Duty(current_duty) ' set new duty ratio,
old_duty = current_duty ' memorize it
PORTB = old_duty ' and display on PORTB
end if
Delay_ms(20) ' slow wn change pace a little
wend
end.
Thanks for looking.........Al
Last edited: