Thanks
It works now. I kind of wondered if I'd have missed something glaringly
obvious, or not very well documented if you don't know exactly what you
are looking for.
Thanks also for the link to the stm8s.h file.
Regards
Russ.
On 24/01/17 07:13, Травкин Роман wrote:
You haven't enabled interrupts. Assembler command "rim" -- enables
interrrupts, "sim" --disasbles.
add __asm__ ("rim") before while(1).
PD_DDR = 1<<3;
PD_CR1 = 1<<3;
__asm__ ("rim");
while(1){
}
You may also may look at adapted stm8s.h from SPL
https://yadi.sk/d/Asn1BiuX3AbQsB
24.01.2017, 00:23, "aarrgghh.co.uk" <aarrg...@aarrgghh.co.uk>:
Thanks I've tried that but I'm still not having any luck.
This is my code.
#include <stdint.h>
#define CLK_DIVR (*(volatile uint8_t *)0x50C6)
#define TIM1_CR1 (*(volatile uint8_t *)0x5250)
#define TIM1_IER (*(volatile uint8_t *)0x5254)
#define TIM1_SR1 (*(volatile uint8_t *)0x5255)
#define TIM1_CNTRH (*(volatile uint8_t *)0x525E)
#define TIM1_CNTRL (*(volatile uint8_t *)0x525F)
#define TIM1_PSCRH (*(volatile uint8_t *)0x5260)
#define TIM1_PSCRL (*(volatile uint8_t *)0x5261)
#define PD_ODR (*(volatile uint8_t *)0x500f)
#define PD_DDR (*(volatile uint8_t *)0x5011)
#define PD_CR1 (*(volatile uint8_t *)0x5012)
void main(void)
{
CLK_DIVR = 0x00; // Set the frequency to 16 MHz
TIM1_PSCRH = 0x00; // Configure timer
TIM1_PSCRL = 0x80;
TIM1_CR1 = 0x01; //Enable timer
TIM1_IER = 0x01; //Enable interrupt - update event
PD_DDR = 1<<3;
PD_CR1 = 1<<3;
while(1){
}
}
void TIM1_overflow_Handler() __interrupt(11)
{
TIM1_SR1 &= ~1; //reset interrupt
PD_ODR ^= 1 << 3; //toggle LED
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user