//************************************************************************************
//**
//** File name: F:\test\Flowcode1.c
//** Generated by: Flowcode v4.3.9.65
//** Date: Friday, February 10, 2012 17:55:43
//** Licence: Free version
//**
//** ***FREE/DEMO VERSION***
//**
//**
//** NOT FOR COMMERCIAL USE
//**
//** http://www.matrixmultimedia.com
//************************************************************************************
#define MX_PIC
//Defines for microcontroller
#define P16F690
#define MX_EE
#define MX_EE_SIZE 256
#define MX_SPI
#define MX_SPI_BCB
#define MX_SPI_SDI 4
#define MX_SPI_SDO 7
#define MX_SPI_SCK 6
#define MX_UART
#define MX_UART_B
#define MX_UART_TX 7
#define MX_UART_RX 5
#define MX_I2C
#define MX_MI2C
#define MX_I2C_B
#define MX_I2C_SDA 4
#define MX_I2C_SCL 6
#define MX_PWM
#define MX_PWM_CNT 1
#define MX_PWM_TRIS1 trisc
#define MX_PWM_1 5
//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <pic.h>
#endif
//Configuration data
//Internal functions
#include "C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h"
//Macro function declarations
void FCM_Taend();
void FCM_Rul();
//Variable declarations
char FCV_TRYK;
//Macro implementations
void FCM_Taend()
{
}
void FCM_Rul()
{
}
void main()
{
//Initialisation
ansel = 0;
anselh = 0;
//Interrupt initialisation code
option_reg = 0xC0;
//Loop
//Loop: While 1
while (1)
{
//Input
//Input: A3 -> Tryk
trisa = trisa | 0x08;
FCV_TRYK = ((porta & 0x08) == 0x08);
//Switch
//Switch: Tryk?
switch (FCV_TRYK)
{
case 1:
{
//Output
//Output: 1 -> C0
trisc = trisc & 0xfe;
if (1)
portc = (portc & 0xfe) | 0x01;
else
portc = portc & 0xfe;
//Output
//Output: 1 -> C1
trisc = trisc & 0xfd;
if (1)
portc = (portc & 0xfd) | 0x02;
else
portc = portc & 0xfd;
//Output
//Output: 1 -> C2
trisc = trisc & 0xfb;
if (1)
portc = (portc & 0xfb) | 0x04;
else
portc = portc & 0xfb;
//Output
//Output: 1 -> C3
trisc = trisc & 0xf7;
if (1)
portc = (portc & 0xf7) | 0x08;
else
portc = portc & 0xf7;
break;
}
default:
{
//Output
//Output: 0 -> C0
trisc = trisc & 0xfe;
if (0)
portc = (portc & 0xfe) | 0x01;
else
portc = portc & 0xfe;
//Output
//Output: 0 -> C1
trisc = trisc & 0xfd;
if (0)
portc = (portc & 0xfd) | 0x02;
else
portc = portc & 0xfd;
//Output
//Output: 0 -> C2
trisc = trisc & 0xfb;
if (0)
portc = (portc & 0xfb) | 0x04;
else
portc = portc & 0xfb;
//Output
//Output: 0 -> C3
trisc = trisc & 0xf7;
if (0)
portc = (portc & 0xf7) | 0x08;
else
portc = portc & 0xf7;
}
}
}
mainendloop: goto mainendloop;
}
void MX_INTERRUPT_MACRO(void)
{
}
Make: The target "C:\PK2 Lessons\LPC Demo Board\01 Hello World\Hello World.o" is out of date.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F690 "Hello World.asm" /l"Hello World.lst" /e"Hello World.err"
Error[105] C:\PK2 LESSONS\LPC DEMO BOARD\01 HELLO WORLD\HELLO WORLD.ASM 32 : Cannot open file (Include File "AC162061.inc" not found)
Message[302] C:\PK2 LESSONS\LPC DEMO BOARD\01 HELLO WORLD\HELLO WORLD.ASM 38 : Register in operand not in bank 0. Ensure that bank bits are correct.
Halting build on first failure as requested.
Initializing PICkit 2 version 0.0.3.63
Found PICkit 2 - Operating System Version 2.32.0
Target power not detected - Powering from PICkit 2 ( 5.00V)
PIC16F690 found (Rev 0x6)
PICkit 2 Ready
Programming Target (11-02-2012 12:03:21)
PIC16F690 found (Rev 0x6)
Erasing Target
Programming Configuration Memory
Verifying Configuration Memory
PICkit 2 Ready
Ok, there are 3 parts to programming:Have re installed all.
When i load "blink.asm" into MPLAB 8.60 and export it, and save the hex file.
Load the hex file into pickit2, Warning : Hex file loaded is larger than device.
When i try the original hex files from pickit2 , it loads without problems, and the board works.
Try to load the original ASM file "blink.asm again into MPLAB, and program device from mplab, it says...
But board will not work.Rich (BB code):Initializing PICkit 2 version 0.0.3.63 Found PICkit 2 - Operating System Version 2.32.0 Target power not detected - Powering from PICkit 2 ( 5.00V) PIC16F690 found (Rev 0x6) PICkit 2 Ready Programming Target (11-02-2012 12:03:21) PIC16F690 found (Rev 0x6) Erasing Target Programming Configuration Memory Verifying Configuration Memory PICkit 2 Ready
Ok, there are 3 parts to programming, which normally happen very quickly in one step:Have re installed all.
When i load "blink.asm" into MPLAB 8.60 and export it, and save the hex file.
Load the hex file into pickit2, Warning : Hex file loaded is larger than device.
When i try the original hex files from pickit2 , it loads without problems, and the board works.
Try to load the original ASM file "blink.asm again into MPLAB, and program device from mplab, it says...
But board will not work.Rich (BB code):Initializing PICkit 2 version 0.0.3.63 Found PICkit 2 - Operating System Version 2.32.0 Target power not detected - Powering from PICkit 2 ( 5.00V) PIC16F690 found (Rev 0x6) PICkit 2 Ready Programming Target (11-02-2012 12:03:21) PIC16F690 found (Rev 0x6) Erasing Target Programming Configuration Memory Verifying Configuration Memory PICkit 2 Ready
All that will be in the datasheet. http://ww1.microchip.com/downloads/en/devicedoc/41262a.pdf During the programming it is of extreme importance to confer with datasheet. Then using any of the onboard functions like ports, timers, and so on. It is nothing wrong in using Assembler. But have you considered C. By the way is things working as they should now?Is it possible to get a list of know commands for the PIC, ?
C is not all that hard. You can also program in BASIC or Pascal. Both very easy too.Is it possible to find and use a grafics verions, like flowcode that i could build the files in ?
It's too complicated to make it in c, or other languages,
it's easy for you that have been educated in programming.
; *******************************************************************
; PICkit 2 Lesson 2 - "Blink"
;
; First lesson showed how to make an LED turn on,
; Now we'll look at how to make it blink. Delay loops are necessary
; to slow down the on and off commands so they are visible to humans.
; *******************************************************************
; * See Low Pin Count Demo Board User's Guide for Lesson Information*
; *******************************************************************
; * NOTE: The PIC16F690 requires the AC162061 header for debugging *
; *******************************************************************
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin B.0 an output
bcf STATUS,RP0 ; back to Register Page 0
MainLoop:
bsf PORTC,0 ; turn on LED C0
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
bcf PORTC,0 ; Turn off LED C0
OffDelayLoop:
decfsz Delay1,f ; same delay as above
goto OffDelayLoop
decfsz Delay2,f
goto OffDelayLoop
goto MainLoop ; Do it again...
end
It is simply the time it takes to execute each instruction.Some explaning would be nice here.
decfsz Delay1,fRich (BB code):; ******************************************************************* ; PICkit 2 Lesson 2 - "Blink" ; ; First lesson showed how to make an LED turn on, ; Now we'll look at how to make it blink. Delay loops are necessary ; to slow down the on and off commands so they are visible to humans. ; ******************************************************************* ; * See Low Pin Count Demo Board User's Guide for Lesson Information* ; ******************************************************************* ; * NOTE: The PIC16F690 requires the AC162061 header for debugging * ; ******************************************************************* #include <p16F690.inc> __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF) cblock 0x20 Delay1 ; Define two file registers for the Delay2 ; delay loop endc org 0 Start: bsf STATUS,RP0 ; select Register Page 1 bcf TRISC,0 ; make IO Pin B.0 an output bcf STATUS,RP0 ; back to Register Page 0 MainLoop: bsf PORTC,0 ; turn on LED C0 OndelayLoop: decfsz Delay1,f ; Waste time. goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec. ; call it a two-tenths of a second. bcf PORTC,0 ; Turn off LED C0 OffDelayLoop: decfsz Delay1,f ; same delay as above goto OffDelayLoop decfsz Delay2,f goto OffDelayLoop goto MainLoop ; Do it again... end
goto OndelayLoop , How can the process know how long to make the delay ? on step by step, it just repeting this again and again..
DECFSZ Decrement f, Skip if 0
Syntax: [ label ] DECFSZ f,d
Operands: 0 ≤ f ≤ 127
d ∈ [0,1]
Operation: (f) - 1 → (destination);
skip if result = 0
Status Affected: None
Description: The contents of register f are
decremented. If d is 0, the result
is placed in the W register. If d is
1, the result is placed back in
register f.
If the result is 1, the next
instruction is executed. If the
result is 0, then a NOP is
executed instead, making it a
two-cycle instruction.
by Duane Benson
by Duane Benson
by Jake Hertz
by Jake Hertz